import discord
import random
from discord.ext import commands
TOKEN='MyToken'
client = commands.Bot(command_prefix = '$')
@client.event
async def on_ready():
await client.change_presence(game=discord.Game(name='the love spreading!', type=3))
print('## Startup Complete ##')
@client.command()
async def love(user1: discord.Member,
user2: discord.Member):
love=random.randint(0,100)
await client.say(':heart:' + str(love) + '%:heart: \n ' + str(user1) + ' + '+ str(user2))
client.run(TOKEN)
嘿,它只是说“ @ TheAlexGamer#7679”而不是ping,为什么? (我删除了将@添加到用于stackoverflow的字符串中的部分)
答案 0 :(得分:0)
因为在discord上写入@TheAlexGamer#7679
时,discord客户端会自动将其更改为<@id_of_alexgmer>
。
要使用漫游器对某人执行ping操作,请使用member.mention
属性。
@client.command()
async def love(user1: discord.Member,
user2: discord.Member):
love=random.randint(0,100)
await client.say(':heart:' + str(love) + '%:heart: \n ' + user1.mention + ' + '+ user2.mention)
client.run(TOKEN)