无法将嵌入内容发送到某些不和谐频道

时间:2020-07-09 14:36:21

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

我正在尝试通过以下方法将嵌入消息发送到指定的频道。但是,当我单独或与其他任何内容一起放入时,嵌入消息不会发送。但是,发送字符串效果很好。

@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def report(ctx, user, reason):
    if ctx.channel.id == 730496513255669881:
            channel = bot.get_channel(730432681657237594)
            embedstaff = discord.Embed(title="A new player report has been submitted!", color=0xff6a00)
            embedstaff.add_field(name="Player/User Reported", value=ctx.author.name, inline=True)
            embedstaff.add_field(name="Reporter", value="Lol", inline=True)
            embedstaff.add_field(name="Report Reason: " + reason, value="", inline=False)
            await channel.send("Heyy x3", embed = embedstaff)

是否存在将消息发送到指定频道的替代方法?还是我现在使用的方法有解决方案? (怎么说角色也很好哈哈)

1 个答案:

答案 0 :(得分:0)

一旦获得Role对象,就可以使用role.mention提及角色。您可以使用get

中的discord.utils来获取角色
from discord.utils import get
#inside a command
role = get(ctx.guild.roles, name='role')
await ctx.send(f'Hello {role.mention}')

通过ID提取频道并将嵌入内容发送到该频道是标准方法。也就是说,Guild具有诸如system_channel, afk_channel, rules_channel之类的属性。因此,如果设置了其中任何一个,您都可以从ctx

rules = ctx.guild.rules_channel

回答标题后,您可以检查要向其发送嵌入内容的频道是否启用了嵌入功能。

相关问题