@client.event 排除其他命令 discord bot python
@client.event excludes other commands discord bot python
这个@client.event
排除了其他命令!!!请帮助我!
async def on_message(message): if client.user.mention in message.content.split(): await message.channel.send('xyz')
这是我的代码:(没有 @client.event 它可以正常工作,但是当我添加其他 @client.event 时,其余代码不起作用,只有 client.event 有效。伙计们帮助!!!
@client.event
async def on_ready():
print('xyz ~ {0.user}'.format(client))
await client.change_presence(activity=discord.Game(name="Piwo?"))
@client.command()
@has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, reason="Za darmo lamusie"):
await member.ban(reason=reason)
await ctx.channel.send(f"***xyz***")
@client.command()
@has_permissions(kick_members=True)
async def kick(ctx, member : discord.Member, reason="Za darmo lamusie"):
await member.kick(reason=reason)
await ctx.channel.send(f"***{member.mention} xyz ***")
@client.command()
async def jaka_gierka(ctx):
gierki = [xyz]
await ctx.channel.send(random.choice(gierki))
@client.command()
async def graj(ctx, game):
await client.change_presence(activity=discord.Game(name=game))
@client.command()
async def streamuj(ctx, game):
await client.change_presence(activity=discord.Streaming(name=game, url="xyz"))
@client.command()
async def sluchaj(ctx, music):
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=music))
@client.command()
async def ogladaj(ctx, film):
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=film))
@client.event
async def on_message(message):
if client.user.mention in message.content.split():
await message.channel.send('xyz')
client.run("token")```
你需要process commands in on_message
.
如果不这样做,将执行 none 条命令。默认行为是 on_message
只处理命令。但是,您创建了自定义事件处理程序,因此必须手动完成。您可以将 on_message
更改为:
顺便说一句,检查消息中的 <@1234>
提及顺序是个坏主意。相反,您可以使用 mentions
.
@client.event
async def on_message(message):
if client.user in message.mentions: # checks if the bot was in the list of people mentioned
await message.channel.send('xyz')
await client.process_commands(message)
这个@client.event
排除了其他命令!!!请帮助我!
async def on_message(message): if client.user.mention in message.content.split(): await message.channel.send('xyz')
这是我的代码:(没有 @client.event 它可以正常工作,但是当我添加其他 @client.event 时,其余代码不起作用,只有 client.event 有效。伙计们帮助!!!
@client.event
async def on_ready():
print('xyz ~ {0.user}'.format(client))
await client.change_presence(activity=discord.Game(name="Piwo?"))
@client.command()
@has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, reason="Za darmo lamusie"):
await member.ban(reason=reason)
await ctx.channel.send(f"***xyz***")
@client.command()
@has_permissions(kick_members=True)
async def kick(ctx, member : discord.Member, reason="Za darmo lamusie"):
await member.kick(reason=reason)
await ctx.channel.send(f"***{member.mention} xyz ***")
@client.command()
async def jaka_gierka(ctx):
gierki = [xyz]
await ctx.channel.send(random.choice(gierki))
@client.command()
async def graj(ctx, game):
await client.change_presence(activity=discord.Game(name=game))
@client.command()
async def streamuj(ctx, game):
await client.change_presence(activity=discord.Streaming(name=game, url="xyz"))
@client.command()
async def sluchaj(ctx, music):
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=music))
@client.command()
async def ogladaj(ctx, film):
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=film))
@client.event
async def on_message(message):
if client.user.mention in message.content.split():
await message.channel.send('xyz')
client.run("token")```
你需要process commands in on_message
.
如果不这样做,将执行 none 条命令。默认行为是 on_message
只处理命令。但是,您创建了自定义事件处理程序,因此必须手动完成。您可以将 on_message
更改为:
顺便说一句,检查消息中的 <@1234>
提及顺序是个坏主意。相反,您可以使用 mentions
.
@client.event
async def on_message(message):
if client.user in message.mentions: # checks if the bot was in the list of people mentioned
await message.channel.send('xyz')
await client.process_commands(message)