Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

discord channel link in message

Tags:

python

bots

Using discord.py, I am making a bot to send users a direct message if a keyword of their choosing is mentioned.

Everything is working, except I just want to add the channel they were mentioned in to the message. Here is my code:

        print("SENDING MESSAGE")
        sender = '{0.author.name}'.format(message)
        channel = message.channel.name
        server = '{0.server}'.format(message)
        await client.send_message(member, server+": #"+channel+": "+sender+": "+msg)

This results in a correct message being composed, but the #channel part of the message is not a clickable link as it would be if i typed it into the chat window myself. Is there a different object I should be feeding into the message?

like image 481
Charlie Avatar asked Oct 22 '25 12:10

Charlie


1 Answers

In Discord: there is channel mention. Try that way, do message.channel.mention instead of message.channel.name it should able to link a channel in PM or everywhere.

Source: Discord Documentation

like image 175
Maverun Avatar answered Oct 24 '25 01:10

Maverun