【发布时间】:2021-05-06 21:08:08
【问题描述】:
我试图让我的机器人将某人键入的任何内容粘贴到消息中,并且当他们不键入任何内容时不允许他们使用该命令,因此使用 &test random text 它将显示 random text,如果我执行&test 会显示错误消息you have to type something in 或类似的内容,
import discord
import os
from discord.ext import commands
from keep_alive import keep_alive
import random
from discord import Member, Embed
from discord.ext.commands import BucketType, cooldown
from discord.ext.commands import errors
import asyncio
@client.command()
@cooldown(4, 11, BucketType.user)
async def test(ctx, args, *, question):
response = ""
for arg in args:
response = response + " " + arg
embed=discord.Embed(title="\"" + response + "\"", colour=ctx.author.colour)
embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url)
somegifs = random.choice(gifs)
embed.set_image(url=somegifs)
embed.set_footer(text="Test embed")
await ctx.send(embed=embed)
@test.error
async def test_error(ctx, error):
if isinstance(error, errors.MissingRequiredArgument):
embed2 = discord.Embed(title="you have to type something in", colour=ctx.author.colour)
embed2.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url)
embed2.set_footer(text="Test embed")
await ctx.send(embed=embed2)
else: raise(error)
这就是我正在使用的,每次我使用命令时,不管是不是文本,它都会显示错误消息, 编辑:再次测试该命令后,它会响应,但只有当您输入多个单词并且它只显示第一个单词,字母之间有空格as shown here
【问题讨论】:
-
什么问题,有什么错误吗?
-
单独使用命令时显示错误消息,仅使用一个单词的命令时,如果使用多个单词,则仅显示第一个单词
标签: python python-3.x discord discord.py