Здесь улучшен ответ @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();
}
Я предполагаю, что у вас есть проблемы с захватом ответа. 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")