Z
Z
ZI7PPER2021-01-22 12:40:10
Python
ZI7PPER, 2021-01-22 12:40:10

How to use the discord.py library to accept a response to a message and store it in a variable?

I've searched a lot, but I haven't found an answer to the above question anywhere.

My bot should create a notification for all participants that at such and such a time, on such and such an IP, a survey will be made. And another comment.

Here is my code:

@bot.command()
async def video(ctx, *, text):
    author = ctx.message.author
    if get(author.roles, name="Босс"):
        await ctx.send(f'Введите время проведение съемок в формате ЧЧ:ММ')
        time = await bot.wait_for('message')
        await ctx.send(f'Теперь введите IP сервера съемок, как он есть')
        serverip = await bot.wait_for('message')
        await ctx.send(f'Теперь введите любой комментарий')
        comment = await bot.wait_for('message')
        embed = discord.Embed(color = discord.Color.red(), title ="**Запланированы сьемки!**", description = '**Время: **' + str(time) + '\n' + '**IP Сервера: **' + str(serverip) + '\n' + '**Комментарий: **' + str(comment) + '\n\n' + '<@everyone>')
        await ctx.send(embed = embed)
    elif text == "?":
        embed = discord.Embed(color = 0xff9900, description = '', title = 'Команда **video**' + "\n" + "\n" + 'Позволяет быстро объявить о предстоящем видео' + "\n" + "Использование: **_/video set_**")
        await ctx.send(embed=embed)
    else:
        await ctx.send(f'Для использования этой команды нужно обладать ролью <@Босс>. К сожалению, у Вас такой роли не обнаружено')


I've only found one function that works for me, but I've never been able to set it up properly so that it just stores the response in a variable.

Here's what my code outputs, which of course doesn't suit me:
600a9c190f4fa613308527.png

Thanks in advance for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-01-22
@ZI7PPER

Here and in other wait_fors, you get a Message object.

time = await bot.wait_for('message')
serverip = await bot.wait_for('message')

Accordingly, work with them as with ordinary Message.
embed = discord.Embed(color = discord.Color.red(), title ="**Запланированы сьемки!**", description = '**Время: **' + time.content + '\n' + '**IP Сервера: **' + serverip.content + '\n' + '**Комментарий: **' + comment.content + '\n\n' + '<@everyone>')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question