コード例 #1
0
ファイル: Commands.cs プロジェクト: bdhood/DiscordSwearBot
        public async Task CounterMM(CommandContext ctx)
        {
            DbConnection conn  = new DbConnection(Bot.dbSettings);
            DbApi        dbApi = new DbApi(conn);

            int total = dbApi.GetServerTotal();

            total--;
            dbApi.SetServerTotal(total);
            await ctx.Channel.SendMessageAsync("Server Counter: " + total.ToString()).ConfigureAwait(false);
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: bdhood/DiscordSwearBot
        public async Task SwearBot(CommandContext ctx)
        {
            DbConnection conn  = new DbConnection(Bot.dbSettings);
            DbApi        dbApi = new DbApi(conn);

            string[] args = ctx.Message.Content.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            if (args.Length == 1)
            {
                int total = dbApi.GetServerTotal();
                await ctx.Channel.SendMessageAsync("Server Counter: " + total.ToString()).ConfigureAwait(false);
            }
            else if (args.Length == 2)
            {
                if (args[1].StartsWith("<@!") && args[1].EndsWith(">"))
                {
                    int user_total = dbApi.UserGetTotal(args[1]);
                    await ctx.Channel.SendMessageAsync("Counter for " + args[1] + " is " + user_total.ToString()).ConfigureAwait(false);
                }
            }
        }