Discord SelfBot:加入服务器/公会时直接向用户发送消息

2024-10-02 00:41:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建一个机器人来运行我的个人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)

Tags: importselfasyncondefbotawaitcommand
2条回答

不太确定,但自助机器人违反了discord的服务条款https://discord.com/new/guidelines

Self bots are not authorized on Discord and can get your account banned.

Discord's API provides a separate type of user account dedicated to automation, called a bot account. Bot accounts can be created through the applications page, and are authenticated using a token (rather than a username and password). Unlike the normal OAuth2 flow, bot accounts have full access to all API routes without using bearer tokens, and can connect to the Real Time Gateway. Automating normal user accounts (generally called "self-bots") outside of the OAuth2/bot API is forbidden, and can result in an account termination if found.

您将无法使用官方的discord.py模块执行此类操作,如果您选择其他方式来构建一个自助机器人,我不确定您是否能够收到StackOverflow方面的帮助

相关问题 更多 >

    热门问题