私はユーザーに(メッセージで言及した)プロフィール写真を送信しようとしています。コマンドの作成者のプロフィール写真を取得する方法は知っていますが、言及したユーザーに対してそれを行う方法がわかりません。彼のIDを取得する方法を理解できましたが、彼のプロフィール写真を送信する方法を見つけることができません。
著者のプロフィール写真を送信するためのコードは次のとおりです。
@bot.command()
@commands.cooldown(1, 10.0, commands.BucketType.guild)
async def hd(msg):
message = str(msg.message.content)
if message[-1] == "d":
await msg.send(msg.author.mention + " You have to mention someone !")
return
id = (message[4:-1])
id = str(id[3:-1] + id[-1])
if str(msg.author.id) == id:
await msg.send(msg.author.mention + " You are not able to use the command on yourself !")
author = msg.message.author
img = author.avatar_url
await msg.send(img)
コマンドをサブクラス化した場合、Insulaの答えは正常に機能するはずです。そうでない場合は、
@bot.command()
async def avatar(ctx, member : discord.Member = None):
await ctx.send(member.avatar_url)
discord.Memberは、コマンド引数をdiscord.Memberインスタンスに変換するコンバーターです。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加