Reputation: 141
I have a small giveaway check on a bot and i would like to point people towards the giveaway if they have not entered. The only issue is that #bottest is being shown as plain text and not an active link to the channel.
@bot.command(name='giveaway')
async def giveaway(ctx, *test):
if len(test) == 0:
user = ctx.message.author
if discord.utils.get(user.roles, name="giveaway"):
await ctx.send(f"Hello {ctx.author.mention} you are entered into the Giveaway! Good luck!")
else:
await ctx.send(f"Hello {ctx.author.mention} you haven't yet entered the Giveaway! Head on over to #bottest to take part")
How do i direct link to the channel in the else message posted by the bot?
Upvotes: 0
Views: 574
Reputation: 1979
The above solution works but you would have to specify the channel each time. Instead if the channel is fixed, you can call it like this:
bottestchannel = bot.get_channel(channel_id_goes_here)
# rest of the code
await ctx.send(f"Hello {ctx.author.mention} you haven't yet entered the Giveaway! Head on over to {bottestchannel.mention} to take part")
Or this also works fine:
else:
await ctx.send(f"Hello {ctx.author.mention} you haven't yet entered the Giveaway! Head on over to <#channel_id_goes_here> to take part")
Upvotes: 1
Reputation:
You can add one more parameter to the cmd
async def giveaway(ctx, channel: discord.TextChannel, *test):
also change last line to await ctx.send(f"Hello {ctx.author.mention} you haven't yet entered the Giveaway! Head on over to {channel.mention} to take part")
Upvotes: 0