Answer the question
In order to leave comments, you need to log in
Discord bot on Discord.py. How to display text through the console?
Discord bot on Discord.py, Python
There is a code with which when you enter text into the command line, this text is displayed on the server. It is necessary to supplement it in such a way that first the ID of the channel to which the message should be sent is entered, and then the message itself is displayed. But before that, you will have to change @bot.command(pass_context=True) to @bot.event so that it is displayed in the console when the bot starts
Or you can do 2 ways so that the message is displayed in the channel to which the last command was sent to the bot
The code itself :
@bot.command(pass_context=True)
async def say(ctx):
say_at_me = input("Введите сообщение через консоль: ")
await ctx.send(say_at_me)
Answer the question
In order to leave comments, you need to log in
Hey! If it's still relevant: I have a code in which you need to write the following command on the server in any channel:
!say(command) #channel (with #)
we get the text: !say #chat Hello World
The code itself:
# Sending a message from bot name
@Bot.command()
@commands.has_permissions(administrator= True)
async def say(ctx, channel : discord.TextChannel, *args):
await ctx.message.delete()
if not channel:
await ctx.send( 'Enter the channel you want to send the message to')
return
if not args:
await ctx.send('You must enter the text of the message')
text = ''
for item in args:
text = text + item + ' '
await channel.send(text)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question