Answer the question
In order to leave comments, you need to log in
Help with cogs. EN: Help with kogami. Two events not working at the same time?
English: Hello! Don't work two events at the same time.
Ru: Hello! Two events do not work at the same time.
import discord
from discord.ext import commands
banwords = ['free nitro']
class Events(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(message):
await bot.process_commands(message)
member = message.author
role = discord.utils.get(member.guild.roles, id = 916301099508576307)
if role in member.roles:
return
elif message.author.bot:
return
elif "https://" in message.content.lower():
print('[Logs:utils] Была обнаружена ссылка! Удаляем!')
await message.delete()
await message.channel.send("Ссылки запрещены!")
@commands.Cog.listener()
async def on_message(message):
await bot.process_commands(message)
if message.author.bot:
return
elif "free nitro" in message.content.lower():
print('[Logs: utils] Было обнаружено запрещенное слово! Удаляем!')
await message.delete()
await message.channel.send('Был обнаружен банворд, со списком запрещенных слов можно ознакомится в соглашении бота. -Binfo')
@commands.Cog.listener()
async def on_message(self, message):
print(message)
def setup(bot):
bot.add_cog(Events(bot))
Answer the question
In order to leave comments, you need to log in
They shouldn't work like that. You can put the code in 1 function.
@commands.Cog.listener()
async def on_message(message):
await bot.process_commands(message)
member = message.author
role = discord.utils.get(member.guild.roles, id = 916301099508576307)
if role in member.roles:
return
if message.author.bot:
return
if "https://" in message.content.lower():
print('[Logs:utils] Была обнаружена ссылка! Удаляем!')
await message.delete()
await message.channel.send("Ссылки запрещены!")
if "free nitro" in message.content.lower():
print('[Logs: utils] Было обнаружено запрещенное слово! Удаляем!')
await message.delete()
await message.channel.send('Был обнаружен банворд, со списком запрещенных слов можно ознакомится в соглашении бота. -Binfo')
print(message)
Conditional block with free nitro still doesn't work and doesn't throw an error
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question