@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) 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() if "@everyone" in message.content: try: await message.author.send(text) except discord.HTTPException: await message.channel.send(f'{message.author.mention} {text}') 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.') ctx = await self.bot.get_context(message) if not ctx.command: return self.bot.prom.commands.inc({"name": ctx.command.name}) if message.guild: if message.guild.id in self.bot.banned_guilds: await message.guild.leave() return permissions = message.channel.permissions_for(message.guild.me) if permissions.send_messages is False: return elif permissions.embed_links is False: await message.channel.send("The Embed Links permission is needed for basic commands to work.") return if message.author.id in self.bot.banned_users: await ctx.send( embed=discord.Embed(description="You are banned from the bot.", colour=self.bot.error_colour) ) return if ctx.command.cog_name in ["Owner", "Admin"] and ( ctx.author.id in self.bot.config.admins or ctx.author.id in self.bot.config.owners ): embed = discord.Embed( title=ctx.command.name.title(), description=ctx.message.content, colour=self.bot.primary_colour, timestamp=datetime.datetime.utcnow(), ) embed.set_author(name=f"{ctx.author} ({ctx.author.id})", icon_url=ctx.author.avatar_url) if self.bot.config.admin_channel: await self.bot.http.send_message(self.bot.config.admin_channel, None, embed=embed.to_dict()) if ctx.prefix == f"<@{self.bot.user.id}> " or ctx.prefix == f"<@!{self.bot.user.id}> ": ctx.prefix = self.bot.tools.get_guild_prefix(self.bot, message.guild) await self.bot.invoke(ctx)