ctx 是缺少的必需参数
ctx is a required argument that is missing
帮我解决这个错误“discord.ext.commands.errors.MissingRequiredArgument: ctx 是必需的
缺少的参数。”在下面编写的代码中
import aiohttp
import discord
from discord.ext import commands
from discord.utils import get
@client.command()
async def cat(self, ctx):
async with aiohttp.ClientSession() as cs:
async with cs.get("https://randomfox.ca/floof/") as r:
data = await r.json()
emb = discord.Embed(title = "Hi!")
emb.set_image(url=data['image'])
emb.set_footer(text =f"Requested By:{ctx.author.name}")
await ctx.send(embed = emb)
你只在classes中使用self
参数(除非是staticmethod
或classmethod
),命令不在class中, 所以你根本就不要接受
async def cat(ctx):
...
帮我解决这个错误“discord.ext.commands.errors.MissingRequiredArgument: ctx 是必需的 缺少的参数。”在下面编写的代码中
import aiohttp
import discord
from discord.ext import commands
from discord.utils import get
@client.command()
async def cat(self, ctx):
async with aiohttp.ClientSession() as cs:
async with cs.get("https://randomfox.ca/floof/") as r:
data = await r.json()
emb = discord.Embed(title = "Hi!")
emb.set_image(url=data['image'])
emb.set_footer(text =f"Requested By:{ctx.author.name}")
await ctx.send(embed = emb)
你只在classes中使用self
参数(除非是staticmethod
或classmethod
),命令不在class中, 所以你根本就不要接受
async def cat(ctx):
...