Пример #1
0
        public async Task Ban(SocketGuildUser nTarget, [Remainder] string reason = null)
        {
            SocketGuildUser sender = this.Context.Guild.GetUser(this.Context.User.Id);

            if (!(sender.CheckUserIsStaff()))
            {
                return;
            }

            if (!sender.RoleSuperiorityCheck(nTarget))
            {
                return;
            }

            AkiraPunishmentModel model = new AkiraPunishmentModel(sender, nTarget, AkiraPunishmentModel.PunishmentType.BAN, reason);

            if (AkiraConfiguration.SendKickedUsersMessage)
            {
                IDMChannel channel = await nTarget.GetOrCreateDMChannelAsync();

                string toSend = $"I'm sorry to inform you but you have been banned from {this.Context.Guild.Name}{(string.IsNullOrEmpty(reason) ? "" : $" for: {nReason}")}.";

                if (!string.IsNullOrEmpty(AkiraConfiguration.AkiraDiscordInviteLink))
                {
                    toSend += $"\nYou may rejoin the server with the following link: {AkiraConfiguration.AkiraDiscordInviteLink} if unbanned.";
                }

                await channel.SendMessageAsync(toSend);
            }

            await this.Context.Guild.AddBanAsync(nTarget, reason : reason);
        }
Пример #2
0
        public static bool LogPunishment(AkiraPunishmentModel nModel)
        {
            string cmdText = GetSqlScript(AkiraSqlScripts.LogPunishment);

            using (SqlCommand cmd = new SqlCommand(cmdText, SqlConn))
            {
                cmd.Parameters.AddWithValue("punisherName", nModel.Sender.Username);
                cmd.Parameters.AddWithValue("punisherID", nModel.Sender.Id.ToString());

                cmd.Parameters.AddWithValue("punishedName", nModel.Target.Username);
                cmd.Parameters.AddWithValue("punishedID", nModel.Target.Id);

                cmd.Parameters.AddWithValue("action", Enum.GetName(typeof(PunishmentType), nModel.Punishment));
                cmd.Parameters.AddWithValue("reason", string.IsNullOrEmpty(nModel.Reason) ? DBNull.Value : nModel.Reason);
                cmd.Parameters.AddWithValue("duration", nModel.RevertTime.HasValue ? nModel.RevertTime.Value : DBNull.Value);

                return(cmd.ExecuteNonQuery() > 0);
            }
        }