Exemplo n.º 1
0
        public async Task StartAsync()
        {
            var client = new DiscordSocketClient();
            Bot.Client = client;
            Bot.Client.Log += Client_Log;

            _commands = new CommandsPlugin(Bot.Client);
            _admincommands = new CommandsPlugin(Bot.Client, (e, s) => { return BotTools.Tools.GetPerms(s, e as IGuildUser); }, '-');
            _commands.CreateCommandGroup("", group => BuildCommands(group));
            _admincommands.CreateCommandGroup("", adminGroup => BuildAdminCommands(adminGroup));

            BotTools.Setup.GetProgramInfo();

            Bot.Client.UserJoined += BotTools.ChatEventActions.UserJoinedAsync;
            Bot.Client.UserLeft += BotTools.ChatEventActions.UserLeftAsync;
            Bot.Client.UserBanned += BotTools.ChatEventActions.UserBannedAsync;
            Bot.Client.MessageReceived += BotTools.ChatEventActions.MessageReceivedAsync;
            Bot.Client.Disconnected += BotTools.ChatEventActions.DisconnectedAsync;


            _commands.CommandError += async (s, e) =>
            {
                if (e.Command.Text == "ayy")
                    return;

                var ex = e.Exception;
                if (ex is PermissionException)
                    await BotTools.Tools.ReplyAsync(e, "Sorry, you do not have the permissions to use this command!");
                else
                    await BotTools.Tools.ReplyAsync(e, $"Error: {ex.Message}.");

            };

            
            await Modules.AnimeTools.AuthorizeAnilistAsync();
            await LoginAsync();

            await Task.Delay(-1);

        }
Exemplo n.º 2
0
 internal CommandGroupBuilder(CommandsPlugin plugin, string prefix, int minPerm)
 {
     _plugin = plugin;
     _prefix = prefix;
     _defaultMinPermissions = minPerm;
 }