/// <summary> /// Initializes the bot object, connects, and runs the active loop. /// </summary> public void InitAndRun(string[] args) { DiscordBotBaseHelper.StartBotHandler(args, new DiscordBotConfig() { CommandPrefix = DenizenMetaBotConstants.COMMAND_PREFIX, Initialize = (bot) => { PopulateFromConfig(bot.ConfigFile); DefaultCommands(bot); bot.Client.Ready += () => { bot.Client.SetGameAsync("Type !help").Wait(); return(Task.CompletedTask); }; }, UnknownCommandHandler = (command, args, message) => { if (message.MentionedUserIds.Contains(DiscordBotBaseHelper.CurrentBot.Client.CurrentUser.Id)) { message.Channel.SendMessageAsync(embed: UserCommands.GetErrorMessageEmbed("Unknown Command", "Unknown command. Consider the __**help**__ command?")).Wait(); } else if (args.Count == 0 && InformationalData.ContainsKey(command.ToLowerFast())) { InfoCmds.CMD_Info(new string[] { command.ToLowerFast() }, message); } }, ShouldPayAttentionToMessage = (message) => { return(message.Channel is IGuildChannel); } }); }
/// <summary> /// Software entry point - starts the bot. /// </summary> static void Main(string[] args) { DiscordBotBaseHelper.StartBotHandler(args, new DiscordBotConfig() { CommandPrefix = "!", Initialize = (bot) => { InfoCommands infoCommands = new InfoCommands() { Bot = bot }; VotingCommands voteCommands = new VotingCommands() { Bot = bot }; CoreCommands coreCommands = new CoreCommands(IsAdmin) { Bot = bot }; AdminCommands adminCommands = new AdminCommands() { Bot = bot }; OwningGuildID = bot.ConfigFile.GetUlong("guild_id").Value; VoteTopicsSection = bot.ConfigFile.GetSection("vote_topics"); if (VoteTopicsSection == null) { VoteTopicsSection = new FDSSection(); bot.ConfigFile.Set("vote_topics", VoteTopicsSection); } Admins = new HashSet <ulong>(bot.ConfigFile.GetStringList("admins").Select(s => ulong.Parse(s))); // Info bot.RegisterCommand(infoCommands.CMD_Help, "help", "halp", "hlp", "hal", "hel", "h", "?", "use", "usage"); bot.RegisterCommand(infoCommands.CMD_Hello, "hello", "hi", "whoareyou", "what", "link", "info"); // Voting bot.RegisterCommand(voteCommands.CMD_Ballot, "ballot", "b"); bot.RegisterCommand(voteCommands.CMD_Vote, "vote", "v"); bot.RegisterCommand(voteCommands.CMD_ClearVote, "clearvote", "voteclear", "cv"); // Admin bot.RegisterCommand(coreCommands.CMD_Restart, "restart"); bot.RegisterCommand(adminCommands.CMD_CallVote, "callvote"); bot.RegisterCommand(adminCommands.CMD_EndVote, "endvote"); bot.RegisterCommand(adminCommands.CMD_VoteStatus, "votestatus"); bot.Client.Ready += () => { bot.Client.SetGameAsync("With the balance of power in this world.").Wait(); return(Task.CompletedTask); }; }, ShouldPayAttentionToMessage = (message) => { //return message.Channel is IPrivateChannel || IsAdmin(message.Author); return(true); } }); }