前提
Discord PyでBotを作っています。
実現したいこと
!webhookでチャンネルWebhookを作成し、メッセージを送信したいです。
発生している問題・エラーメッセージ
Ignoring exception in command webhook: Traceback (most recent call last): File "/home/runner/Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "main.py", line 314, in webhook await create_webhook(name="mywebhook") NameError: name 'create_webhook' 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/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/home/runner/Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/home/runner/Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'create_webhook' is not defined
該当のソースコード
Python
1import discord 2from discord.ext import commands 3import random 4from discord import Permissions 5from colorama import Fore, Style 6import asyncio 7from flask import Flask 8from threading import Thread 9from discord import Embed 10intents = discord.Intents(messages=True, guilds=True, members=True) 11 12token = "トークン" 13 14client = commands.Bot(command_prefix="!", intents=intents) 15 16activity = discord.Game(name="ゲーム") 17 18@client.event 19async def on_ready(): 20 21 await client.change_presence(status=discord.Status.online, activity=activity) 22 23@client.command() 24async def webhook(ctx): 25 await create_webhook(name="mywebhook") 26 27client.run(token, bot=True)
試したこと
create_webhookをmanage_webhooksに変えてみたりもしました…

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。