前提
DisnakeでBotを作っています。
ユーザーIDでユーザーを取得する機能を実装中にエラーが発生しました。
実現したいこと
- 取得機能を動作するようにする
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/ext/commands/slash_core.py", line 730, in invoke await call_param_func(self.callback, inter, self.cog, **kwargs) File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/ext/commands/params.py", line 1022, in call_param_func return await maybe_coroutine(safe_call, function, **kwargs) File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/utils.py", line 599, in maybe_coroutine return await value File "main.py", line 190, in find_id user = await fetch_user(userid) NameError: name 'fetch_user' is not defined The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1353, in process_application_commands await app_command.invoke(interaction) File "/home/runner/Bot/venv/lib/python3.8/site-packages/disnake/ext/commands/slash_core.py", line 739, in invoke raise CommandInvokeError(exc) from exc disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'fetch_user' is not defined
該当のソースコード
py
1@bot.slash_command() 2async def find_id(inter, userid: str): 3 """ 4 Parameters 5 ---------- 6 user_id: ユーザーのIDを入力して下さい 7 """ 8 user = await fetch_user(userid) 9 10 embed = disnake.Embed( 11 title=f"ID = {userid}", 12 color=disnake.Colour.yellow(), 13 timestamp=datetime.datetime.now(), 14 ) 15 16 embed.add_field("**NAME**", value=f"{user.name}", inline=False) 17 embed.add_field("タグ", value=f"{user.discriminator}", inline=False) 18 embed.add_field("?", value=f"{user}", inline=False) 19 20 await inter.response.send_message(embed=embed)
試したこと
他にも検索してみたが、該当の結果が得られなかった
補足情報(FW/ツールのバージョンなど)
実行環境はReplitです
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/01/19 08:53