示例#1
0
 private async Task OnGuildEmojisUpdated(GuildEmojisUpdateEventArgs e)
 {
     if (GuildEmojisUpdated != null)
     {
         await GuildEmojisUpdated(e);
     }
 }
示例#2
0
        public static async Task EmojiUpdated(GuildEmojisUpdateEventArgs e, DiscordClient client)
        {
            DiscordEmoji added = e.EmojisAfter.Except(e.EmojisBefore).FirstOrDefault();

            await client.SendMessageAsync(e.Guild.Channels.Where(x => x.Name == "general").FirstOrDefault(), "Hinnye! Új emoji lett létrehozva " + added.CreationTimestamp +
                                          "-kor " + added.Name + " néven!");
        }
示例#3
0
 private async Task OnEmojiChanged(GuildEmojisUpdateEventArgs e)
 {
     if (Program.Settings.ListenedGuilds.Contains(e.Guild.Id))
     {
         await EmoteHandler.ReloadEmojiAll();
     }
     await Task.Yield();
 }
示例#4
0
        private async Task OnGuildEmojiUpdate(GuildEmojisUpdateEventArgs eventArgs)
        {
            var guild = await cacheHandler.Guilds.GetAsync(eventArgs.GuildId)
                        ?? new DiscordGuildPacket
            {
                Id = eventArgs.GuildId
            };

            guild.Emojis = eventArgs.Emojis.ToArray();
            await cacheHandler.Guilds.EditAsync(guild);
        }
示例#5
0
 private Task GuildEmojisUpdated(GuildEmojisUpdateEventArgs e)
 {
     /* This would kill my bot */
     return(Task.CompletedTask);
 }
示例#6
0
 private Task Client_GuildEmojisUpdated(GuildEmojisUpdateEventArgs e)
 {
     e.Client.DebugLogger.LogMessage(LogLevel.Info, "BotApp", e.ToString(), DateTime.Now);
     return(Task.CompletedTask);
 }
示例#7
0
        public static async Task GuildEmojisUpdateEventHandlerAsync(TheGodfatherShard shard, GuildEmojisUpdateEventArgs e)
        {
            DiscordChannel logchn = shard.SharedData.GetLogChannelForGuild(shard.Client, e.Guild);

            if (logchn == null)
            {
                return;
            }

            DiscordEmbedBuilder emb = FormEmbedBuilder(EventOrigin.Emoji, "Guild emojis updated");

            AuditLogActionType action;

            if (e.EmojisAfter.Count > e.EmojisBefore.Count)
            {
                action = AuditLogActionType.EmojiCreate;
            }
            else if (e.EmojisAfter.Count < e.EmojisBefore.Count)
            {
                action = AuditLogActionType.EmojiDelete;
            }
            else
            {
                action = AuditLogActionType.EmojiUpdate;
            }
            DiscordAuditLogEntry entry = await e.Guild.GetFirstAuditLogEntryAsync(action);

            emb.WithTitle($"Guild emoji action occured: {action.ToString()}");
            if (entry == null || !(entry is DiscordAuditLogEmojiEntry eentry))
            {
                emb.AddField("Error", "Failed to read audit log information. Please check my permissions");
                emb.AddField("Emojis before", e.EmojisBefore?.Count.ToString() ?? _unknown, inline: true);
                emb.AddField("Emojis after", e.EmojisAfter?.Count.ToString() ?? _unknown, inline: true);
            }
            else
            {
                switch (action)
                {
                case AuditLogActionType.EmojiCreate:
                    emb.WithDescription(eentry.Target.Name ?? _unknown);
                    emb.WithThumbnailUrl(eentry.Target.Url);
                    break;

                case AuditLogActionType.EmojiDelete:
                    emb.WithDescription(eentry.NameChange.Before ?? _unknown);
                    break;

                case AuditLogActionType.EmojiUpdate:
                    emb.WithDescription(eentry.Target.Name ?? _unknown);
                    if (eentry.NameChange != null)
                    {
                        emb.AddField("Name changes", $"{Formatter.InlineCode(eentry.NameChange.Before ?? "None")} -> {Formatter.InlineCode(eentry.NameChange.After ?? "None")}", inline: true);
                    }
                    break;

                default:
                    break;
                }
                emb.AddField("User responsible", eentry.UserResponsible.Mention, inline: true);
                if (!string.IsNullOrWhiteSpace(eentry.Reason))
                {
                    emb.AddField("Reason", eentry.Reason);
                }
                emb.WithFooter(eentry.CreationTimestamp.ToUtcTimestamp(), eentry.UserResponsible.AvatarUrl);
            }

            await logchn.SendMessageAsync(embed : emb.Build());
        }
示例#8
0
 private async Task GuildEmojisUpdated(DiscordClient c, GuildEmojisUpdateEventArgs e)
 {
     this.logger.Information($"Guild '{e.Guild.Name}' ({e.Guild.Id}) has updated their emojis.");
 }
示例#9
0
 private Task Event_GuildEmojisUpdated(DiscordClient d, GuildEmojisUpdateEventArgs e)
 {
     d.Logger.LogDebug(BotEventId, "Event_GuildEmojisUpdated.");
     return(Task.CompletedTask);
 }
示例#10
0
 internal static Task EmojiUpdated(DiscordClient _1, GuildEmojisUpdateEventArgs e)
 {
     throw new NotImplementedException();
 }