来自的说明fetch_channel是一个API调用,它应该返回与get_channel相同的东西(返回通道)。
我尝试使用client.get_channel来获取我的dm频道,但它返回None。但在我将其更改为client.fetch_channel后,它工作得很好。
我在discord.ext.tasks.loop函数中调用了它们(该函数将每隔n秒调用一次),如下所示:
# this alarmSender() will be called every 10 seconds
@tasks.loop(seconds=10)
async def alarmSender():
chnl
我想在DM中创建一个提示符,我试着使用它,但它不起作用。 @client.command()
async def event(ctx):
await ctx.send("Prompt will continue in DMs.")
embed = discord.Embed(title="Event Prompt", description="Please specify the type of event.")
embed.set_footer(text="Prompt will expire in 30 se
当用户对带有复选标记的消息做出反应时,我该如何使用python中的discord bot向用户发送dm?例如,假设我让我的python机器人发送一条消息,当用户对此做出反应时,它会向该用户发送一个包含信息的dm。 ? 这是我能够构建的代码,我猜它是如何工作的,显然它不是python语法。谢谢! if user.reaction == ✅:
member.send("Nice to know you checked the message thanks")
我想要做的是,当机器人启动时,抓取好友列表,并对其中的每个人进行DM。我不能使用ctx,因为on_ready不支持它。到目前为止我的代码如下:
@bot.event
async def on_ready(msg):
for x in bot.user.friends:
e = x.id
await x.send('hi')
我有它,所以我的机器人删除,并在它的坏话消息。由于某些原因,如果我在一行中做了两个坏词,它会删除第一条消息和dm的me一次,然后删除另外两条消息和dm的me两次。有人能告诉我我做错了什么吗? @client.event
async def on_message(message):
bad_words = ['bad','bot']
user = client.get_user(647589407515213866)
for word in bad_words:
if (message.content.count(word
我尝试让我的机器人使用以下语法从DM获取消息:
for wolf in wolf_list_id:
poll_message = await self.client.get_message(wolf, react_message.id)
wolf包含用户的id,但是get_message语法不能从wolf获取id。有什么想法吗?
我想知道如何塑造一个永远不变的特定的人。我尝试过许多StackOverFlow帖子和官方的discord.py文档,但都没有用。我有discord.py 1.7.3。到目前为止,我得到了以下信息:
import discord
from discord.ext import commands
@client.command()
async def dm(ctx):
user = client.get_user(1234567891011) # <- This user will always be the same.
await user.send("Hi
我正在尝试获取提到的用户(而不是DM对话中涉及的用户)。到目前为止,我已经写了这篇文章,如果在通道中使用,它可以工作,但是在DM中使用时就不能工作: if message.content.startswith('!hello'):
user = message.server.get_member_named(message.content.split()[1])
await client.send_message(user, "you got message!") 如果在DM中使用,上面的代码总是返回AttributeError: 'N
因此,我目前正在做一个软禁令命令,我希望用户能够在每个dm上发送一个新的inv链接。但这并不是在向他们传达信息。这是我的密码。谢谢!
@client.command(pass_context=True)
async def softban(ctx, user: discord.User=None):
if user == None:
embed = discord.Embed(title=f"**Softban**",
description=f"Softban will ban but
我正在尝试让我的机器人响应接受规则的DM消息。
这是我到目前为止所知道的:
@bot.event
async def on_member_join(member):
role = discord.utils.get(member.servers.roles, name='Newcomers') #get role
await bot.add_roles(member, role) #give the role to the user
await bot.member.send("Welcome to the Moderator Bot Server! I w
如何获得频道的名称,以便这个机器人可以在其放置的任何服务器上工作,而不需要更改代码?(在我放置"what do I put here“的代码中,我希望名称位于变量中)。
from discord.ext.commands import Bot
import time, asyncio
TOKEN = 'Its a secret'
BOT_PREFIX = ["!"]
client = Bot(command_prefix=BOT_PREFIX)
@client.event
async def on_message(message):
i