Charlie
Charlie

Reputation: 1289

discord channel link in message

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?

Upvotes: 4

Views: 12759

Answers (1)

Maverun
Maverun

Reputation: 56

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

Upvotes: 4

Related Questions