python - 我如何将两个嵌入合二为一?不和谐.py

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

所以我有一个帮助命令,可以向您发送有关您的 DM 的命令列表。发送后,我希望它在同一个@bot 或@client.command 中发送另一个嵌入。

import discord
from discord.ext import commands
import etc etc etc

@client.command() async def 帮助(ctx,成员:discord.Member=None):

embed=discord.Embed(title='Commands:',colour = discord.Colour.orange())

embed.add_field(name='Bomb', value=f'Deletes Messages in chat\n .bomb 100', inline=False)
embed.add_field(name='Luck', value=f'Like 8ball fourtune teller', inline=False)
embed.add_field(name='Tof', value=f'True or False', inline=False)

embed.add_field(name='Hitme', value=f'See me holy face', inline=False)
embed.add_field(name='Monkey', value=f'Random pic of monkey monkey', inline=False)
embed.add_field(name='Whois', value=f'Userinfo', inline=False)

embed.add_field(name='coin', value=f'Flips a coin', inline=False)
embed.add_field(name='Dice', value=f'Random number from 1 to 6', inline=False)
embed.add_field(name='Randomnumber', value=f'Gives you a random number from 1 to 100', inline=False)

embed.add_field(name='Meme', value=f'Random meme?', inline=False)
embed.add_field(name='Say', value=f'Says what ever you want the bot to say', inline=False)
embed.add_field(name='Kick', value=f'Kicks user (Needs Admin)', inline=False)

embed.add_field(name='Ban', value=f'Bans user (Needs Admin', inline=False)
embed.add_field(name='Unban', value=f'Revokes ban from user. (Needs Admin)', inline=False)
embed.add_field(name='Prefix', value=f'Changes prefix e.g .prefix !', inline=False)

em.set_author(name='***Commands list has been sent!***')
em.set_footer(name='Check Your DM's! ✅')

await ctx.author.send(embed=embed)

await ctx.send(embed=em)

#I want this to work so it would send this embed after it sent the embed on DM's to the channel 
  #where .help was used. this was my attempt I'm new to python

最佳答案

三件事:

  1. em 从未被定义
  2. em.set_footer 没有对象 name - 它的 text="Check Your DM's! ✅"
  3. ctx.author.send 会将嵌入发送给消息的作者 -> member.send 会将嵌入发送给特定用户

您的代码应如下所示:

@client.command()
async def help(ctx, member:discord.Member = None):
    embed=discord.Embed(title='Commands:',colour = discord.Colour.orange())
    ...

    em = discord.Embed(title="YOU NEED TO SET A TITLE")
    em.set_author(name='***Commands list has been sent!***')
    em.set_footer(text="Check Your DM's! ✅")

    await member.send(embed=embed)

    await ctx.send(embed=em)

为什么要使用 member:discord.Member = None?你什么都不做?

如果你想检查一个成员是否被赋予使用:

if member is None:
   await ctx.send("Please give me a user °_°")
else:
   YOUR CODE...

关于python - 我如何将两个嵌入合二为一?不和谐.py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65020612/

相关文章:

java - 如何根据 react 发送消息,然后根据用户消息发送另一条消息?使用JDA

mysql - Heroku SSL 连接错误不支持的协议(protocol)

python lxml - 选择不带双斜杠的xpath

python - 值错误: need more than one value to unpack

python - Reportlab 中的段落 overflow hidden

python - 找到一对值的最大值并且需要不断重建的最有效的数据结构是什么?

node.js - Discord Oauth2 访问 token 'Grant type None is not supported'

python - 从响应中获取选定的路径

Python:如何在类中动态分配函数名称

django - 'str' 的 Pylint Django 模型实例没有成员