@AleXAndR169

При наличии в коде @bot.event, @bot.commands не работает(делал на python 3.9). Что делать?

import discord 
from discord.ext import commands 

bot = commands.Bot(command_prefix = ".", intents = discord.Intents.all())

@bot.event
async def on_message(message):
	if 'smetanka_v_dele' in message.content.lower():
		await message.channel.send('хозяин занят')
		await bot.process_commands(message)
		
@bot.event
async def on_ready():
	await bot.change_presence(status=discord.Status.idle, activity=discord.Game('SCP secret labaratory'))
	print("I am connected, my lord!")

@bot.event

async def on_member_join( member ):
	channel = bot.get_channel( 888164664012328991 )

	role = discord.utils.get( member.guild.roles, id = 821361329771642902 )

	await member.add_roles( role )
	await channel.send( embed = discord.Embed( description = f'Пользователь { member.name}, присоеденился к нам' ) )

@bot.event
async def on_message_delete(message):
	channel = bot.get_channel(888164664012328991)
	embed = discord.Embed(title = f"Пользователь удалил сообщение {message.content}", description = f"Канал: {message.channel.mention}")
	await channel.send(embed = embed)
	await bot.process_commands(message)

@bot.event
async def on_message_edit(before, after):
	if before.content == after.content:
		return
	await before.channel.send(f"Сообщение было изменено!\n{before.content} -> {after.content}")
	await bot.process_commands(message)

@bot.event
async def on_voice_state_update(member, before, after):
	if before.channel == after.channel:
		return
	if not before.channel:
		channel = bot.get_channel( 888164664012328991 )
		embed = discord.Embed(title = f"Пользователь {member.name} зашёл в голосовой канал", description = f"Канал: {after.channel.mention}", color  = member.color)
		return await channel.send(embed = embed)

	if not after.channel:
		channel = bot.get_channel( 888164664012328991 )
		embed = discord.Embed(title = f"Пользователь {member.name} вышел из голосового канала", description = f"Канал: {before.channel.mention}", color  = member.color)
		return await channel.send(embed = embed)
	else:
		channel = bot.get_channel( 888164664012328991 )
		embed = discord.Embed(title = f"Пользователь {member.name} перешёл в голосовой канал", description = f"Канал до: {before.channel.mention}\nКанал после {after.channel.mention}", color  = member.color)
		return await channel.send(embed = embed)

@bot.command( pass_context = True )
@commands.has_permissions( administrator = True )	

async def kick(ctx, member: discord.Member, *, reason = None ):
	await ctx.channel.purge( limit =1 )

	await member.kick(reason = reason)

@bot.command( pass_context = True )
@commands.has_permissions( administrator = True )	

async def ban(ctx, member: discord.Member, *, reason = None ):
	await ctx.channel.purge( limit =1 )

	await member.ban(reason = reason)
	await ctx.send(f'ban user { member.mention }')

@bot.command()
async def морковка(ctx):
	await ctx.send('нет, это картошка')

@bot.command( pass_context = True )

async def clear( ctx, amount = 100 ):
	await ctx.channel.purge( limit = amount )

bot.run("token")
  • Вопрос задан
  • 356 просмотров
Решения вопроса 1
shurshur
@shurshur
Сисадмин, просто сисадмин...
Так и должно быть в соответствии с написанным. Вызов bot.process_commands(message) случается только тогда, когда сообщение содержит smetanka_v_dele. Вынеси process_commands из if.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы