コード例 #1
0
        public async Task Kick(Discord.IGuildUser user, [Remainder] string reason)
        {
            var b = new Discord.EmbedBuilder();

            b.WithTitle("User Kicked").WithDescription(user.Username + " was kicked because " + reason).WithColor(25, 25, 112);

            await Context.Channel.SendMessageAsync("", false, b);

            await user.KickAsync();
        }
コード例 #2
0
    public async Task KickAsync(Discord.IGuildUser user, [Remainder] string reason)
    {
        if (user.GuildPermissions.KickMembers)
        {
            var b = new Discord.EmbedBuilder();
            b.WithTitle("User Kicked");
            b.WithDescription(user.Username + "was kicked.");
            b.WithColor(new Discord.Color(0, 170, 255));
            await Context.Channel.SendMessageAsync("", false, b);

            await user.KickAsync();
        }
    }
コード例 #3
0
ファイル: Test.cs プロジェクト: Fasuh/bot
        public async Task warn(Discord.IGuildUser user, [Remainder] string reason)
        {
            if (!user.IsBot)
            {
                dbase.chkserver(Context.Guild);
                string       query = "INSERT INTO `warny` (`id`, `user`, `reason`, `date`, `wanner`, `Server`) VALUES (NULL, '" + user.Id + "', @reason, '" + time.Year + "-" + time.Month + "-" + time.Day + "', '" + Context.Message.Author.Id + "', '" + dbase.Chkserver(Context.Guild.Id.ToString()) + "')";
                MySqlCommand cmd   = new MySqlCommand(query, dbase.connect);
                cmd.Parameters.AddWithValue("@reason", reason);
                dbase.make(cmd);
                Console.WriteLine(time + "\t" + user.Username + " zwarnowany za " + reason + " na serwerze " + Context.Guild.Name + "!");
                await Context.Channel.SendMessageAsync(user.Username + " zwarnowany za " + reason + "!");

                query = "SELECT COUNT(*) AS TotalNORows FROM warny as w INNER JOIN `servery` as s ON w.Server = s.id WHERE w.user='******' AND s.nid='" + Context.Guild.Id.ToString() + "'";

                cmd = new MySqlCommand(query, dbase.connect);
                DataTable warn = dbase.Read(cmd);
                if (Int32.Parse(warn.Rows[0][0].ToString()) > 3)
                {
                    if (int.Parse(warn.Rows[0][0].ToString()) > 5)
                    {
                        int    czas   = 2 * (int.Parse(warn.Rows[0][0].ToString()) - 5);
                        string format = "yyyy-MM-dd HH:mm:ss";
                        query = "INSERT INTO `timery` (`id`, `user`, `type`, `time`, `text`, `Server`) VALUES (NULL, '" + user.Id + "', 'ban', '" + time.AddDays(czas).ToString(format) + "', NULL, '" + dbase.Chkserver(Context.Guild.Id.ToString()) + "')";
                        cmd   = new MySqlCommand(query, dbase.connect);
                        dbase.timer(cmd, "ban", time.AddDays(czas), user, Context.Guild.Id.ToString());
                        Console.WriteLine(time + "\tUzytkownik " + user.Username + " zbanowany na serwerze " + Context.Guild.Name + " na " + czas + " dni.");
                        await Context.Channel.SendMessageAsync(user.Mention + " zostal zbanowany na " + czas + " dni.");

                        await user.SendMessageAsync("Zostałeś zbanowany na serwerze " + Context.Guild.Name + " na " + czas + " dni.");

                        await Context.Guild.AddBanAsync(user);
                    }
                    else
                    {
                        Console.WriteLine(time + "\tUzytkownik " + user.Username + " zkickowany na serwerze " + Context.Guild.Name + ".");
                        await Context.Channel.SendMessageAsync(user.Mention + " został zkickowany.");

                        await user.SendMessageAsync("Zostałeś zkickowany na serwerze " + Context.Guild.Name + ".");

                        await user.KickAsync();
                    }
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync("Nie wolno warnować botów. :(");
            }
        }