Discord.py: Is it possible to do this?

Created on 22 Oct 2018  路  4Comments  路  Source: Rapptz/discord.py

I am trying to make a discord bot for my advertising server, and I am still sort of new to coding with discord.py (I have been doing it for about 2 months). I would like to know if someone can type something in chat and then post the author's message in another channel

Example:
User: $ad (in a channel different from the channel the bot will post the message in).
and then the bot posts the author's ad in a certain channel (like a channel for advertisements)

Further Example:
User: $ad join my discord server!
Bot: User said: join my discord server!

I know I haven't really explained it much, but I hope someone can help me, thanks!

All 4 comments

If you get the author's message's ID, you should be able to work off of that if I'm not wrong...

      If you get the author's message's ID, you should be able to work off of that if I'm not wrong...

yeah, that would work thanks

Yes, this is possible.
You can simply use Message.content or, if you're using the commands extension, a keyword-only argument parameter to get the content of the message.
You can get the Channel by ID using Client.get_channel or Server.get_channel (Guild.get_channel on the rewrite branch) or you can filter for the Channel by using Server.channels (Guild.text_channels on the rewrite branch) and utils.find/utils.get.
If you're using the commands extension on the rewrite branch, you can accept the TextChannel as a parameter using TextChannelConverter. On the async branch, to accept it as Channel parameter with the commands extension, you can use ChannelConverter:
https://github.com/Rapptz/discord.py/blob/1863a1c6636f53592519320a173ec9573c090c0b/discord/ext/commands/converter.py#L106

For further help, you should join either the official discord.py server or the Discord API server, as the README recommends.

Was that email really necessary

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adhoc92 picture adhoc92  路  3Comments

synbitz picture synbitz  路  3Comments

AraHaan picture AraHaan  路  3Comments

PicklesJars picture PicklesJars  路  3Comments

Rimmy50 picture Rimmy50  路  3Comments