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>()); }
public async Task HandleEventAsync(object?sender, IUserConnectedEvent @event) { var find = await m_Database.GetBanAsync(@event.User.Id); if (find != null) { if (find.expireDateTime > DateTime.Now) { await m_UserManager.KickAsync(@event.User, m_StringLocalizer["plugin_translations:reason", new { Reason = find.banReason, Time = DateTime.Now.Second + find.expireDateTime.Second }]); return; } } }