【发布时间】:2020-09-16 09:21:11
【问题描述】:
所以,我正在开发一个不和谐的机器人。并且正在使用 on_message() 事件,该事件适用于私人消息和服务器。我希望这只能在私人消息中使用,并且不确定如何去做。 如果有人可以帮助我,那就太好了。
import os
import discord
from discord.ext import commands
TOKEN = ''
quotedUsers = []
client = commands.Bot(command_prefix = '/')
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
await client.change_presence(activity=discord.Game(name='with myself.'))
@client.event
async def on_message(message):
await message.author.send("Recieved: " + message.content)
@client.command()
async def search(ctx, *, question):
await ctx.author.send("Searching: " + question)
client.run(TOKEN)
【问题讨论】:
-
您刚刚发布了您的机器人令牌。您需要尽快重新生成它。
-
@JoshuaNixon Discord 已开始自动获取泄露的令牌并为您自动重新生成 - 您还会收到来自他们的 DM
-
哎呀,我太傻了。现在修好了。 :O
标签: python bots discord discord.py