簡體   English   中英

@提及隨機用戶discord.py

[英]@Mention Random user discord.py

大家好,所以我一直在嘗試編寫一個代碼,其中不和諧機器人從我的服務器中提及隨機用戶,我已經編寫了代碼,但機器人一直在提及自己

from random import choice

@client.command(pass_context=True)
async def best(ctx):
    user = choice(ctx.message.channel.guild.members)
    await ctx.send(f'{user.mention} is the best player')

你必須把 random.choice 而不是選擇

user = random.choice(ctx.message.channel.guild.members)

random.choice 將選擇一個隨機用戶。 選擇什么都不做

嘗試一下:

from discord import Intents

client = Bot(command_perfix='!', intents=Intents.all())

https://discord.com/developers/applications//bot

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM