private async Task HandleWelcomeReactions(Cacheable <IUserMessage, ulong> cacheable, SocketReaction reaction) { if (!((IGuildUser)reaction.User.Value).GuildPermissions.Administrator) { return; } var emote = reaction.Emote; var user = (IGuildUser)cacheable.Value.Author; // TODO: Maybe create another service for this? if (Equals(emote, Emote.Parse(_pairs.GetString("999_EMOTE")))) { await AssignRole(cacheable, reaction, user, UserActions.ClassC); } else if (Equals(emote, Emote.Parse(_pairs.GetString("POGEY_EMOTE")))) { await AssignRole(cacheable, reaction, user, UserActions.Int); } else if (Equals(emote, Emote.Parse(_pairs.GetString("SAD_EMOTE")))) { await AssignRole(cacheable, reaction, user, UserActions.Underage); } else if (Equals(emote, Emote.Parse(_pairs.GetString("RAGEY_EMOTE")))) { await user.BanAsync(); Logger.LogWarning("Emergency ban enacted by {ReactionUser} on {User} ({UserId})", reaction.User, user, user.Id); } }
private async Task <bool> HahaFunni(SocketMessage m) { if (m.Content.Equals("good bot", StringComparison.OrdinalIgnoreCase)) { await m.AddReactionAsync(Emote.Parse(_pairs.GetString("AGRLOVE_EMOTE"))); } else if (m.Content.Equals("bad bot", StringComparison.OrdinalIgnoreCase)) { await m.AddReactionAsync(Emote.Parse(_pairs.GetString("SAD_EMOTE"))); } else if (m.Content.Equals(_pairs.GetString("THANKS_THORN_TRIGGER"), StringComparison.OrdinalIgnoreCase)) { await m.AddReactionAsync(Emote.Parse(_pairs.GetString("AGRLOVE_EMOTE"))); } else if (m.Content.Equals(_pairs.GetString("BODIES_IN_WATER_TRIGGER"), StringComparison.OrdinalIgnoreCase)) { await m.Channel.SendMessageAsync(_random.Next(2) == 0? _pairs.GetString("BODIES_IN_WATER_ERROR") : _pairs.GetString("BODIES_IN_WATER_SUCCESS")); } else if (m.Content.Equals(_pairs.GetString("BODIES_IN_WATER_OHGODOHFUCK_TRIGGER"), StringComparison.OrdinalIgnoreCase)) { await m.Channel.SendMessageAsync(_pairs.GetString("BODIES_IN_WATER_OHGODOHFUCK")); } else { return(false); } return(true); }
public ReactionHandler(DiscordSocketClient client, PairsService pairs, ILogger <ReactionHandler> logger, QuicklinkService quicklink) : base(client, logger) { _client = client; _pairs = pairs; _quicklink = quicklink; _welcomeChannelId = ulong.Parse(_pairs.GetString("WELCOME_CHANNEL_ID")); _loggingChannelId = ulong.Parse(_pairs.GetString("LOGGING_CHANNEL_ID")); _classCRoleId = ulong.Parse(_pairs.GetString("CLASS_C_ROLE_ID")); _intRoleId = ulong.Parse(_pairs.GetString("INT_ROLE_ID")); }
public async Task <Embed> GetEmbedForArticle(string query) { var articles = await GetArticleData(query); if (articles is null) { return(new EmbedBuilder().WithDescription("Tento článek jsem nenašel :(").Build()); } var czech = articles.FirstOrDefault(x => Regex.Match(x.Url, @"scp-cs\.wikidot\.com").Success); var english = articles.FirstOrDefault(x => Regex.Match(x.Url, @"scp-wiki\.wikidot\.com").Success); if (czech == null && english == null) { return(new EmbedBuilder().WithDescription("Tento článek jsem nenašel :(").Build()); } string title, description; List <EmbedFieldBuilder> fieldBuilders; EmbedFooterBuilder footerBuilder; if (czech != null && english != null) { description = $"**Autor: `{english.Attributions.First().User.Name}`**\n" + $"**Překladatel: `{czech.Attributions.First().User.Name}`**"; title = czech.AlternateTitles.FirstOrDefault() == null ? czech.WikidotInfo.Title : $"{czech.WikidotInfo.Title} - {czech.AlternateTitles.First().Title}"; fieldBuilders = new List <EmbedFieldBuilder> { new EmbedFieldBuilder().WithName("Překlad").WithValue($"[link]({czech.Url})").WithIsInline(true), new EmbedFieldBuilder().WithName("Originál").WithValue($"[link]({english.Url})").WithIsInline(true) }; footerBuilder = new EmbedFooterBuilder().WithText($"Hodnocení překladu: {czech.WikidotInfo.Rating}"); } else if (czech != null) { description = $"**Autor: `{czech.Attributions.First().User.Name}`**"; title = czech.AlternateTitles.FirstOrDefault() == null ? czech.WikidotInfo.Title : $"{czech.WikidotInfo.Title} - {czech.AlternateTitles.First().Title}"; fieldBuilders = new List <EmbedFieldBuilder> { new EmbedFieldBuilder().WithName("Odkaz").WithValue($"[link]({czech.Url})").WithIsInline(true) }; footerBuilder = new EmbedFooterBuilder().WithText($"Hodnocení: {czech.WikidotInfo.Rating}"); } else { description = $"**Autor: `{english.Attributions.First().User.Name}`**\n" + $"Zatím nepřeloženo {_pairs.GetString("SAD_EMOTE")}"; title = english.AlternateTitles.FirstOrDefault() == null ? english.WikidotInfo.Title : $"{english.WikidotInfo.Title} - {english.AlternateTitles.First().Title}"; fieldBuilders = new List <EmbedFieldBuilder> { new EmbedFieldBuilder().WithName("Odkaz").WithValue($"[link]({english.Url})").WithIsInline(true) }; footerBuilder = new EmbedFooterBuilder().WithText($"Hodnocení: {english.WikidotInfo.Rating}"); } return(new EmbedBuilder { Title = title, Description = description, Color = Color.Blue, Fields = fieldBuilders, Footer = footerBuilder }.Build()); }