Ummm, So I am in dier need of help. I am wanting to make it where my bot blocks certain channels from having links being sent. Like, The general channel. I dont want links to be sent there but in #advertisment i dont mind. What do i do about that?
This will find if the message contains a URL and is in your discussion channel. You can get a channels ID by either typing \\#ChannelName
in any chat in your channel or by right-clicking on it and selecting "Copy ID". If you want only URLs in #advertisment you could do message.channel.id != "advertisment id"
.
import re
@client.event
async def on_message(message):
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content.lower())
if url and message.channel.id == "your general channel id"
await client.delete_message(message)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.