我正在尝试创建一个机器人来运行我的个人discord帐户,并在人们加入我所在的特定discord服务器时直接向他们发送消息。但是,当成员加入服务器时,我的on_member_join(member)方法未运行(未在终端中打印“registered”)。我很好奇如何让bot监听特定的服务器,或者只是一般地注册这个事件。注意_connect()和spam()都能正常工作
import discord
import asyncio
import requests
from discord.ext import commands
yer=commands.Bot(command_prefix="!",help_command=None,self_bot=True)
token="TOKEN"
class SelfBot(commands.Cog):
def __init__(self,yer):
self.yer=yer
@yer.command()
async def spam(ctx):
for i in range(50):
await ctx.send("Hello!")
await asyncio.sleep(0.7)
@yer.event
async def on_connect():
await yer.change_presence(status=discord.Status.idle,activity=discord.Game("Game"))
@yer.event
async def on_member_join(member):
print("registered")
yer.run(token,bot=False)
不太确定,但自助机器人违反了discord的服务条款https://discord.com/new/guidelines
Self bots are not authorized on Discord and can get your account banned.
您将无法使用官方的
discord.py
模块执行此类操作,如果您选择其他方式来构建一个自助机器人,我不确定您是否能够收到StackOverflow方面的帮助相关问题 更多 >
编程相关推荐