Discord Bot ctx 只捕获第一个词

Discord Bot ctx only capturing first word

from discord.ext import commands
import random

description = '''An example bot to showcase the discord.ext.commands extension
module.

There are a number of utility commands being showcased here.'''
bot = commands.Bot(command_prefix='?', description=description)

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')




#here i need the help

@bot.command()
async def idea(ctx, content):
    """Repeats a message multiple times."""
    await ctx.send(content)
    f= open("supersmartidea.txt","a")
    f.write("¦" + content + "\n")

机器人只保护输入的第一个词为 ctx,所以如果我输入 ?idea 这是个好主意, 只有 "this" 被写下来。 机器人应该写下 "this is a great idea" 我以前从未编写过机器人代码,不知道如何修复它。

您可以通过两种方式获取全部内容。

这将给出一串他们所说的内容。例如 ?idea A good idea 将 return: A good idea

@bot.command()
async def idea(ctx, *, content):
    #code

这将 return 每个单词的元组。例如:?idea A good idea will return: ('A', 'good', 'idea') 然后你可以通过 content = ' '.join(content)

把它变成一个字符串
@bot.command()
async def idea(ctx, *content):
    #code

这可以通过使用以下 .join 功能实现。

@bot.command()
async def idea(ctx, content):
    """Repeats a message multiple times."""
    message = (" ").join(content)
    await ctx.send(message)