如何使用 python 在不和谐机器人中提及

时间:2021-04-01 14:14:43

标签: python-3.x discord.py

if message.content.startswith('Imagine'):
    #Mentioned or not
    if len(message.mentions) == 0:
    #no one is mentioned
    return
pinged_user = message.mentions[0]
await message.channel.send([pinged_user, "got ora ora ora'd and is no longer with us"])

Right now when I try it, it shows this I want it to show this

#另一个问题,我希望只有当你说“想象(提到的人)生活”时才会发生 提前致谢!

1 个答案:

答案 0 :(得分:0)

欢迎堆栈溢出!这很完美,希望对您有所帮助。

import discord
from discord.ext import commands

prefix = "!"
intents = discord.Intents.default()
client = commands.Bot(command_prefix=prefix, intents=intents)

@client.event
async def on_ready():
    print('connected to Discord as {0.user}'.format(client))
    await client.change_presence(activity=discord.Game(name="example"))


@client.command()
async def imagine(ctx, member: discord.Member = None):
    if member == None: return
    await ctx.send(f"{member.mention} got ora ora ora'd and is no longer with us")

client.run('token')

Example of the command