@commands.Cog.listener() async def on_message(self, message): if message.author.bot: return if message.guild != None: data = await self.bot.get_data(message.guild.id) if message.mentions: for mention in message.mentions: afk = await self.bot.get_member_guild(mention.id, message.guild.id) server_info = self.bot.get_channel(id = 500413330368888882) # Server Info channel text = f"Please don't mention `@everyone` unnecessarily. If you want to ping a large group of members we have roles for activities or games which can be found in {server_info.mention} or you could ping `@here`." if bad := [word for word in data[28] or self.bot.config.default_bad_words if word in message.content]: #if message.content in data[28] or message.content in self.bot.config.default_bad_words: #if message.author.has_any_role(data[3]) or message.author.has_guild_permissions(self.bot.config.moderator_permissions): if (len(set(data[3]) & set([role.id for role in message.author.roles])) > 0) or self.bot.config.moderator_permissions in message.author.guild_permissions: return else: await message.delete() # It's bit that's not working but everyhting folowing does (well about from the commented out if statement but I'm hoping `message.mentions_everyone` will fix that try: await message.author.send(f'Your message had `{", ".join(bad)}` in it, This word is conssidered a "bad" word on this server so your message was removed.') except discord.HTTPException: await message.channel.send(f'{message.author.mention} `{bad}` is conssidered a "bad" word on this server.') #if "@everyone" in message.content: if message.mention_everyone: try: await message.author.send(text) except discord.HTTPException: await message.channel.send(f'{message.author.mention} {text}')