protected override async Task OnExecuteAsync() { if (Context.Parameters.Length < 1) { throw new CommandWrongUsageException(Context); } var userId = await Context.Parameters.GetAsync <string>(0); var find = await m_MySqlDatabase.GetBanAsync(userId); if (find != null) { throw new UserFriendlyException(m_StringLocalizer["plugin_translations:uban_not_found", new { Name = userId }]); } await Context.Actor.PrintMessageAsync(m_StringLocalizer["plugin_translations:unban_success", new { Name = userId }]); await m_MySqlDatabase.UpdateLastBanAsync(userId, true); await m_WebhookService.SendEmbedAsync(new Models.DiscordMessage { embeds = new List <Models.Embed> { new Models.Embed { title = "UnBan Register", color = 23131, fields = new List <Models.Field> { new Models.Field { name = "UserId", value = userId, inline = true }, new Models.Field { name = "ModeratorName", value = Context.Actor.DisplayName, inline = true }, new Models.Field { name = "ModeratorId", value = Context.Actor.Id, inline = true } }, } } }, m_Configuration.GetSection("plugin_configuration:UnBanWebHookURL").Get <string>()); }
protected override async Task OnExecuteAsync() { if (Context.Parameters.Length < 1) { throw new CommandWrongUsageException(Context); } var toKick = await Context.Parameters.GetAsync <IUser>(0); if (toKick == null) { throw new UserFriendlyException(m_StringLocalizer["plugin_translations:not_found", new { Name = await Context.Parameters.GetAsync <string>(0) }]); } string reason; if (Context.Parameters.Length >= 2) { reason = await Context.Parameters.GetAsync <string>(1); } else { reason = m_StringLocalizer["plugin_translations:no_reason"]; } await Context.Actor.PrintMessageAsync(m_StringLocalizer["plugin_translations:kick_success", new { Name = toKick.DisplayName, Reason = reason }], System.Drawing.Color.Magenta); await m_UserManager.KickAsync(toKick, reason); await m_WebhookService.SendEmbedAsync(new Models.DiscordMessage { embeds = new List <Models.Embed>() { new Models.Embed { title = "Kick Register", color = 23131, fields = new List <Models.Field> { new Models.Field { name = "UserName", value = toKick.DisplayName, inline = true }, new Models.Field { name = "UserId", value = toKick.Id, inline = true }, new Models.Field { name = "PunisherName", value = Context.Actor.DisplayName, inline = true }, new Models.Field { name = "PunisherId", value = Context.Actor.Id, inline = true }, new Models.Field { name = "KickReason", value = reason, inline = true }, }, } } }, m_Configuration.GetSection("plugin_configuration:KickWebHookURL").Get <string>()); }
protected override async Task OnExecuteAsync() { if (Context.Parameters.Length < 1) { throw new CommandWrongUsageException(Context); } var toBan = await Context.Parameters.GetAsync <IUser>(0); if (toBan == null) { throw new UserFriendlyException(m_StringLocalizer["plugin_translations:not_found", new { Name = await Context.Parameters.GetAsync <string>(0) }]); } string reason; if (Context.Parameters.Length >= 2) { reason = await Context.Parameters.GetAsync <string>(1); } else { reason = m_StringLocalizer["plugin_translations:no_reason"]; } DateTime expireDate; if (Context.Parameters.Length >= 3) { var time = await Context.Parameters.GetAsync <double>(2); expireDate = DateTime.Now.AddSeconds(time); await Context.Actor.PrintMessageAsync(m_StringLocalizer["plugin_translations:ban_success", new { Name = toBan.DisplayName, Reason = reason, Time = time }], System.Drawing.Color.Magenta); } else { expireDate = DateTime.MaxValue; await Context.Actor.PrintMessageAsync(m_StringLocalizer["plugin_translations:ban_success", new { Name = toBan.DisplayName, Reason = reason, Time = "permanent" }], System.Drawing.Color.Magenta); } await m_UserManager.KickAsync(toBan, m_StringLocalizer["plugin_translations:reason", new { Reason = reason, Time = DateTime.Now.Second - expireDate.Second }]); await m_MySqlDatabase.AddBanAsync(new Models.Ban { userId = toBan.Id, punisherId = Context.Actor.Id, banReason = reason, unBanned = false, expireDateTime = expireDate, banDateTime = DateTime.Now }); await m_WebhookService.SendEmbedAsync(new Models.DiscordMessage { embeds = new List <Models.Embed>() { new Models.Embed { title = "Ban Register", color = 23131, fields = new List <Models.Field> { new Models.Field { name = "UserName", value = toBan.DisplayName, inline = true }, new Models.Field { name = "UserId", value = toBan.Id, inline = true }, new Models.Field { name = "PunisherName", value = Context.Actor.DisplayName, inline = true }, new Models.Field { name = "PunisherId", value = Context.Actor.Id, inline = true }, new Models.Field { name = "BanReason", value = reason, inline = true }, new Models.Field { name = "BanTime", value = expireDate.ToString(), inline = true } }, } } }, m_Configuration.GetSection("plugin_configuration:BanWebHookURL").Get <string>()); }