Discord bot только считывает первое слово строки, а не всю строку [duplicate]

Здесь улучшен ответ @lucasjones. Я включил улучшения, упомянутые в разделе комментариев после его ответа. Я надеюсь, что кто-то найдет это полезным.

public static string[] GetTypePropertyNames(object classObject,  BindingFlags bindingFlags)
{
    if (classObject == null)
    {
        throw new ArgumentNullException(nameof(classObject));
    }

        var type = classObject.GetType();
        var propertyInfos = type.GetProperties(bindingFlags);

        return propertyInfos.Select(propertyInfo => propertyInfo.Name).ToArray();
 }
1
задан YwM 23 May 2018 в 20:12
поделиться

1 ответ

Я предполагаю, что у вас есть проблемы с захватом ответа. discord.py перегружает синтаксис function(args, *, kwargs) для команд, так что один аргумент после * является текстом остальной части сообщения.

from discord.ext.commands import Bot

bot = Bot('#')

my_user_id = "<Your ID>"  
# You can get your id through the discord client, after activating developer mode.

@bot.command(pass_context=True)
async def survey(ctx):
    await bot.send_message(ctx.message.author, "What's your name?")

@bot.command(pass_context=True)
async def respond(ctx, *, response):
    owner = await bot.get_user_info(my_user_id)
    await bot.send_message(owner, "{} responded: {}".format(ctx.message.author.name, response))

bot.run("token")
1
ответ дан Patrick Haugh 17 August 2018 в 09:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: