コード例 #1
0
ファイル: Moderation.cs プロジェクト: jpmac26/JackFrost-Bot
        public static async void Ban(string moderator, ITextChannel channel, SocketGuildUser user, string reason)
        {
            try {
                //Ban user
                await user.Guild.AddBanAsync((IUser)user, 0, reason);

                //Announce ban in channel where infraction occured
                var embed = Embeds.Ban(user, reason);
                await channel.SendMessageAsync("", embed : embed).ConfigureAwait(false);

                //Log ban in bot-logs
                embed = Embeds.LogBan(moderator, channel, user, reason);
                var botlog = await channel.Guild.GetTextChannelAsync(UserSettings.Channels.BotLogsId(user.Guild.Id));

                if (botlog != null)
                {
                    await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);
                }
            }
            catch
            {
                await channel.SendMessageAsync(UserSettings.BotOptions.GetString("NoPermissionMessage", channel.Guild.Id));
            }
        }