Skip to content

Commit

Permalink
Merge pull request #38 from Kenysdev/dev
Browse files Browse the repository at this point in the history
Fix '!compile': Add 'fn main' if missing and set python3 as the default
  • Loading branch information
SergioRibera authored Aug 17, 2024
2 parents 13d1d59 + 6d1cbd2 commit b9ad9ff
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/general_commands/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ static LANGUAGE_ALIASES: &[(&str, &str)] = &[
("objc", "objective-c"),
("kt", "kotlin"),
("cs", "csharp"),
("py", "python"),
("py3", "python3"),
("py", "python3"),
("python", "python3"),
("py2", "python"),
("python2", "python"),
("js", "javascript"),
("coffee", "coffeescript"),
("fs", "fsharp"),
Expand Down Expand Up @@ -165,16 +167,16 @@ pub async fn compile(ctx: &Context, msg: &Message) -> CommandResult {

if language == "rust" {
msg.react(ctx, ReactionType::Unicode("🦀".to_string())).await.unwrap();
if !code_block.contains("fn main") {
code_block = format!("fn main() {{\n{}\n}}", code_block);
}
}

if !LANGUAGES.contains(&&*language) {
msg.reply(ctx, format!(
"{INVALID_LANGUAGE} {}",
LANGUAGES.join(", ")
)).await?;
if !code_block.contains("fn main") {
code_block = format!("fn main() {\n{code_block}\n}");
}
return Ok(());
}

Expand Down

0 comments on commit b9ad9ff

Please sign in to comment.