public async Task MainAsync(string[] args) { #if DEBUG //fireBaseEnabled = true; tcpEnabled = true; goto SkipArgs; #endif foreach (string str in args) { if (str == "firebase") { fireBaseEnabled = true; } if (str == "tcp") { tcpEnabled = true; } } SkipArgs: _client = new DiscordSocketClient(); _client.Log += Log; _client.Ready += OnReady; _client.LoggedIn += OnLoggin; _client.Connected += OnConnected; _client.Disconnected += OnDisconnected; _commands = new CommandService(); _commandHandler = new CommandHandler(_client, _commands, BuildServiceProvider()); InfoImportClass.LoadBlackList(); InfoImportClass.LoadWhiteList(); InfoImportClass.LoadAbilityLibrary(); TrelloLink = InfoImportClass.GetTrelloLink(); if (fireBaseEnabled) { firebaseManager = new FirebaseManager(); } if (tcpEnabled) { tcpServer = new TCPServer(); } if (InfoImportClass.LoadDiscordKey(out string discordKey) == false) { await Log(new LogMessage(LogSeverity.Error, "", "Failed to load discord key, bot thus cannot run.")); return; }
public async Task RandomMeme() { RandomResult result = (RandomResult)rand.Next(0, 2); switch (result) { case RandomResult.YoutubeLink: { string meme = InfoImportClass.GetRandomYoutubeLink(); if (meme != "") { await ReplyAsync(meme); } else { await ReplyAsync("Failed to get a meme, message Abe"); await Log("Failed to post youtube link to the channel " + Context.Channel.ToString() + " in the guild " + Context.Guild.ToString(), LogSeverity.Error); break; } break; } case RandomResult.Image: { string meme = InfoImportClass.GetRandomImageFromFile(); if (meme != "") { await Context.Channel.SendFileAsync(meme, ""); } else { await ReplyAsync("Tried to upload image but failed to get one."); await Log("Failed to upload a image to the channel " + Context.Channel.ToString() + " in the guild " + Context.Guild.ToString(), LogSeverity.Error); break; } break; } case RandomResult.Video: { string meme = InfoImportClass.GetRandomVideoFromFile(); if (meme != "") { await Context.Channel.SendFileAsync(meme, ""); } else { await ReplyAsync("Tried to upload a video but failed to get one."); await Log("Failed to upload a video to the channel " + Context.Channel.ToString() + " in the guild " + Context.Guild.ToString(), LogSeverity.Error); break; } break; } default: break; } }