python - 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)
解决方案
推荐阅读
- python - 如何使 Tkinter GUI 线程安全?
- c# - 模型绑定的复杂类型不能是抽象类型或值类型,并且必须具有无参数构造函数
- android - 将apk上传到Nexus,maven插件是唯一的方法吗?
- c# - 有没有一种方法可以获取锁 c# 的递归级别
- javascript - How to send addicional information along with ember Delete model request
- xamarin.forms - Xamarin iOS:如何使用标准阅读器打开 pdf 文件
- powershell - 调用可执行文件时重复的动态参数
- sql - My first question — Violation of PRIMARY KEY constraint
- python - 装饰器的类不能改变类变量
- android - 在 Android Studio 中从 JSON 向谷歌地图添加标记