首页 > 解决方案 > add role by clicking on a link discord.py

问题描述

I'm currently developing a discord bot that grabs the user IP, with their permission. For that I would like that once they clicked on the link I'd display on the embed that the bot has given them the verified role. I'm facing some issues with this.

My code:

import discord
from discord.ext import commands
import requests
from requests import get
from bs4 import BeautifulSoup
import os
import socket
import asyncio

bot = commands.Bot(command_prefix = "!", case_insensitive = True)
BOT_TOKEN = "my_token"

@bot.event
async def on_ready():
    print('Connected to bot: {}'.format(bot.user.name))
    print('Bot ID: {}'.format(bot.user.id))
    print(''' 
 
    ██████╗░░░█████╗░████████╗███████╗░
    ██╔══██╗░██╔══██╗╚══██╔══╝██╔════╝░ 
    ██████╦╝░██║░░██║░░░██║░░░█████╗░░░ 
    ██╔══██╗░██║░░██║░░░██║░░░██╔══╝░░░
    ██████╦╝░╚█████╔╝░░░██║░░░███████╗░
    ╚═════╝░░░╚════╝░░░░╚═╝░░░╚══════╝░
    ''')
    print('\nConnected to bot: {}'.format(bot.user.name))
    print('Bot ID: {}'.format(bot.user.id))
    await bot.change_presence(activity=discord.Game(name="Grabbing your stuff"))

@bot.command()
async def verify(ctx):  
    nome=ctx.author.name
    embed = discord.Embed(
        title=nome,
        description = ':flag_pt:Clica [aqui]("site") para te verificares\n :flag_us:Click [here]("site") to verify',
        colour = discord.Colour.green()
    )

    botmsg = await ctx.send(embed = embed)
    await botmsg.add_reaction("✅")


bot.run(BOT_TOKEN)

标签: pythondiscord.py

解决方案


推荐阅读