Example #1
0
        public static async Task MessageTextReactionEventHandlerAsync(KioskAppShard shard, MessageCreateEventArgs e)
        {
            if (e.Author.IsBot || e.Channel.IsPrivate || string.IsNullOrWhiteSpace(e.Message?.Content))
            {
                return;
            }

            if (e.Message.Content.StartsWith(shard.SharedData.GetGuildPrefix(e.Guild.Id)))
            {
                return;
            }

            if (shard.SharedData.BlockedChannels.Contains(e.Channel.Id) || shard.SharedData.BlockedUsers.Contains(e.Author.Id))
            {
                return;
            }

            if (!e.Channel.PermissionsFor(e.Guild.CurrentMember).HasFlag(Permissions.SendMessages))
            {
                return;
            }

            if (!shard.SharedData.TextReactions.TryGetValue(e.Guild.Id, out ConcurrentHashSet <TextReaction> treactions))
            {
                return;
            }

            TextReaction tr = treactions?.FirstOrDefault(r => r.IsMatch(e.Message.Content));

            if (!tr?.IsCooldownActive() ?? false)
            {
                await e.Channel.SendMessageAsync(tr.Response.Replace("%user%", e.Author.Mention));
            }
        }
        public static async Task MessageTextReactionEventHandlerAsync(TheGodfatherShard shard, MessageCreateEventArgs e)
        {
            if (e.Author.IsBot || e.Channel.IsPrivate || string.IsNullOrWhiteSpace(e.Message?.Content))
            {
                return;
            }

            if (shard.SharedData.BlockedChannels.Contains(e.Channel.Id) || shard.SharedData.BlockedUsers.Contains(e.Author.Id))
            {
                return;
            }

            if (!e.Channel.PermissionsFor(e.Guild.CurrentMember).HasFlag(Permissions.SendMessages))
            {
                return;
            }

            if (!shard.SharedData.TextReactions.ContainsKey(e.Guild.Id))
            {
                return;
            }

            TextReaction tr = shard.SharedData.TextReactions[e.Guild.Id]?.FirstOrDefault(r => r.IsMatch(e.Message.Content));

            if (tr != null && !tr.IsCooldownActive())
            {
                await e.Channel.SendMessageAsync(tr.Response.Replace("%user%", e.Author.Mention));
            }
        }