【问题标题】:Discord Self-Bot: Direct messaging a user when joining a server/guildDiscord Self-Bot:加入服务器/公会时直接向用户发送消息
【发布时间】:2020-12-05 04:05:39
【问题描述】:

我正在尝试创建一个机器人来运行我的个人 discord 帐户,并在人们加入我所在的特定 discord 服务器时直接向他们发送消息。但是,当成员加入服务器时,我的 on_member_join(member) 方法没有运行(不在终端打印“已注册”)。我很好奇如何让机器人监听特定的服务器,或者一般只注册这个事件。注意 on_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)

【问题讨论】:

    标签: python python-3.x discord discord.py chatbot


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      Discord 的 API 提供了一种单独类型的专用于自动化的用户帐户,称为机器人帐户。机器人帐户可以通过应用程序页面创建,并使用令牌(而不是用户名和密码)进行身份验证。与正常的 OAuth2 流程不同,机器人帐户无需使用承载令牌即可完全访问所有 API 路由,并且可以连接到实时网关。 禁止在 OAuth2/bot API 之外自动化普通用户帐户(通常称为“self-bots”),如果发现,可能会导致帐户终止。

      您将无法使用官方的 discord.py 模块做这些事情,如果您选择其他东西来构建自我机器人,我不确定您是否能够在 StackOverflow 上获得帮助。

      【讨论】:

        猜你喜欢
        • 2019-01-16
        • 1970-01-01
        • 2021-01-09
        • 2021-09-30
        • 2018-08-27
        • 2020-01-22
        • 2021-09-10
        • 2021-05-15
        • 2021-01-12
        相关资源
        最近更新 更多