public async Task UserAlertRemove(string link, params IGuildUser[] users) { if (!users.Any()) { await ReplyAsync(resourceManager.GetString( nameof(UserAlertModuleResource.UserNotFound))); return; } if (!(Context.Message.Author as IGuildUser).Guild.Roles.Any(x => x.Permissions.Administrator) && users.Any(x => x.Id != Context.Message.Author.Id)) { await ReplyAsync(resourceManager.GetString( nameof(UserAlertModuleResource.OnlyAdminAlertSomeoneElse))); return; } var mangaId = crawlerService.SiteCrawler.GetMangaId(); await userAlertService.Remove(Context.Guild.Id, users.Select(x => x.Id), mangaId, crawlerService.SiteCrawler.MangaSite); await dbContext.SaveChangesAsync(); await ReplyAsync(resourceManager.GetString( nameof(UserAlertModuleResource.UserAlertRemoveSuccess))); }
public async Task ServerAlertRemoveAllConfirm() { await serverAlertService.Remove(Context.Guild.Id); await userAlertService.Remove(Context.Guild.Id); await dbContext.SaveChangesAsync(); await ReplyAsync(resourceManager.GetString( nameof(ServerAlertModuleResource.ServerAlertRemoveAllConfirmSuccess))); }
private async Task SendServerMessage(string user, string mangaName, ulong serverId, MangaRelease mangaRelease) { var culture = CultureInfo.GetCultureInfo(ServerLocalizerService.Languages.FirstOrDefault(x => x.Key == serverId).Value ?? "en-US"); var message = user + Environment.NewLine + string.Format(resourceManager.GetString( nameof(WebJobResource.NewRelease), culture), mangaName, mangaRelease.LastRelease, mangaRelease.MangaSite.ToString()); if (mangaRelease.MangaSite == MangaSite.TuManga || mangaRelease.MangaSite == MangaSite.UnionMangas) { message += Environment.NewLine + string.Format(resourceManager.GetString( nameof(WebJobResource.CheckItOnline), culture), mangaRelease.MangaSite == MangaSite.TuManga ? "https://tmofans.com/library/manga/{mangaSiteId}/discans" : "https://unionmangas.top/manga/{mangaRelease.MangaSiteId}"); } if (mangaRelease.MangaSite == MangaSite.UnionMangas || mangaRelease.MangaSite == MangaSite.InfoAnime) { message += Environment.NewLine + string.Format(resourceManager.GetString( nameof(WebJobResource.ScanInfo), culture), mangaRelease.ScanName, mangaRelease.ScanLink); } if (discord.GetGuild(serverId) == null) { await userAlertService.Remove(serverId); await serverAlertService.Remove(serverId); } var dbChannel = await channelService.GetByServerId(serverId); try { if (dbChannel != null) { await(discord .GetGuild(serverId) .GetChannel(dbChannel.ChannelId) as SocketTextChannel) .SendMessageAsync(message); } else { message += Environment.NewLine + Environment.NewLine + string.Format(resourceManager.GetString( nameof(WebJobResource.NoChannel), culture), $"{Consts.BotCommand}{ConfigureModule.ChannelCommand}"); await discord .GetGuild(serverId) .DefaultChannel .SendMessageAsync(message); } return; } catch { } foreach (var channel in discord.GetGuild(serverId).TextChannels) { try { await channel.SendMessageAsync(message); return; } catch { } } // todo: save notification to send again - discord server error maybe }