Discord Self-Bot:加入 server/guild 时直接向用户发送消息
Discord Self-Bot: Direct messaging a user when joining a server/guild
我正在尝试通过我的个人 discord 帐户为 运行 创建一个机器人,并在人们加入我所在的特定 discord 服务器时直接向他们发送消息。但是,我的 on_member_join(会员)当成员加入服务器时,方法不是 运行ning(不在终端中打印“已注册”)。我很好奇如何让机器人侦听特定服务器或只是一般地注册此事件。注意 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)
不太确定,但自助机器人违反了 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
模块执行此类操作,而且我不确定如果您选择其他模块来构建self-bot.
我正在尝试通过我的个人 discord 帐户为 运行 创建一个机器人,并在人们加入我所在的特定 discord 服务器时直接向他们发送消息。但是,我的 on_member_join(会员)当成员加入服务器时,方法不是 运行ning(不在终端中打印“已注册”)。我很好奇如何让机器人侦听特定服务器或只是一般地注册此事件。注意 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)
不太确定,但自助机器人违反了 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
模块执行此类操作,而且我不确定如果您选择其他模块来构建self-bot.