我有一个不和谐的机器人驻留在多个服务器上,但是我希望每个服务器都有加入消息,或者确保我的机器人只向加入其中一个服务器的人发送欢迎消息。 @client.event #Send new members of the server a message
async def on_member_join(member): #Run when a member joins
await member.create_dm() #Create a DM chat with the new user
await member.dm_channel.send(f"Heya, {membe
我正在学习如何使用python创建一个不和谐的机器人,我在使用这个命令时遇到了问题。我想要做的是踢一个特定的用户,然后用机器人把一个invite回传给discord服务器。这是一个愚蠢的想法,但我真的想让它发挥作用。
我特别有问题是如何踢一个特定的用户(使用用户ID),然后DM该用户。
谢谢!
代码如下:
if message.content == '!kickjohn':
if "527290609166188554" in [role.id for role in message.author.roles]:
<KICK JOH
当用户对带有复选标记的消息做出反应时,我该如何使用python中的discord bot向用户发送dm?例如,假设我让我的python机器人发送一条消息,当用户对此做出反应时,它会向该用户发送一个包含信息的dm。 ? 这是我能够构建的代码,我猜它是如何工作的,显然它不是python语法。谢谢! if user.reaction == ✅:
member.send("Nice to know you checked the message thanks")
@client.command()
async def submitclue(ctx):
await ctx.send('Submit your answer')
message = await client.wait_for('message')
print(f"{message.author} is an author of the message.")
if message.content == 'twopeople':
await ctx.send('Answer
我想出了一种方法让DM的人,但是我想知道他们说了什么通过DM返回给机器人,就好像机器人“读取”DM,然后将其转发到我的不一致服务器中的某个频道,或者更好的是,DM将其转发给我。
下面是我的开始代码:
if message.content.startswith("!dm"):
if message.author.id == "[YOUR ID HERE]":
memberID = "ID OF RECIPIENT"
server = message.server
person = discor
所以,我正在制造一个不和谐的机器人,当有人违反规则时,DMs模式的角色。这是我第一个不和谐的机器人,而且刚刚在GitHub上脱离了这个例子。我似乎找不到如何检查一个角色或一个角色中的每个人。我发现了一些东西
if message.author.server_privileges("kick_members"):
还有检查这个角色的东西。虽然它总是说“成员没有属性‘server_privileges’”之类的东西。不管怎样,我希望你们能帮我。这是我最不需要完成的事情。下面是我的代码:
class MyClient(discord.Client):
async def on_
本质上,我试图构建一个机器人,当用户将具有特定关键字的DM作为DM发送给机器人时,该机器人将为用户提供特定的角色。关键字stuff和一切都运行得很完美。服务器的解析是正确的,但我认为我在获取角色或添加角色时犯了一个错误。下面是我的代码中用于角色分配的特定部分: server = client.get_guild(<my server id here>)
role = discord.utils.get(server.roles, name="Member")
await user.add_roles(ctx.message.author, role)
我想要做的是,当机器人启动时,抓取好友列表,并对其中的每个人进行DM。我不能使用ctx,因为on_ready不支持它。到目前为止我的代码如下:
@bot.event
async def on_ready(msg):
for x in bot.user.friends:
e = x.id
await x.send('hi')
尝试让我的机器人用"this is a dm“回复dm,但没有成功,下面是我的代码: @client.event
async def on_message(message):
if message.guild == null:
await message.channel.send('this is a dm')
else:
pass 我也尝试过这样做: @client.event
async def on_message(message):
if isinstance(message.channel, disco
我正在编写我的不一致机器人程序,当你向机器人发送一个DM时,我想有一个不同的命令集。我有一个DM齿轮和一个CHANNELS齿轮。在我的event.on_message中,我的代码是: if message.channel.id in _allowed_channels:
await bot.process_commands(message) 有没有办法做到这一点: if message.guild == None: # Direct messages
await DM.process_commands(message)
else:
await CHANNELS.pro
所以我有这个密码。应该把服务器里的每个人都干掉。它并不是每个人都能做到的,但它只是尝试对运行在代码上的机器人进行DM,因为这是不可能做到的。
@client.command()
async def adm(ctx, *, message):
await ctx.message.delete()
for user in ctx.guild.members:
try:
await user.send(message)
print(f"Sent {user.name} a DM.")
ex