如何在 discord.py 中将 guild_subscriptions 事件设置为 true?
How to set guild_subscriptions event to true in discord.py?
我在 discord.py 中遇到问题,下面的代码是 运行 完美的,但是 ctx.guild.owner
returns none,并且在文档中它说如果发生这种情况,事件 guild_subscriptions
设置为 False
,我如何将此事件设置为 True
以使其工作?我在 discord.py 文档中找不到任何解决方案,在 Google.
中也找不到
我的serverstats
命令的代码:
@commands.command(name="serverstats", aliases = ["serverinfo", "si", "ss", "check-stats", 'cs'])
async def serverstats(self, ctx: commands.Context):
embed = discord.Embed(
color = discord.Colour.orange(),
title = f"{ctx.guild.name}")
embed.set_thumbnail(url = f"{ctx.guild.icon_url}")
embed.add_field(name = "ID", value = f"{ctx.guild.id}")
embed.add_field(name = "Owner", value = f"{ctx.guild.owner}")
embed.add_field(name = "Region", value = f"{ctx.guild.region}")
embed.add_field(name = "Member Count", value = f"{ctx.guild.member_count}")
embed.add_field(name = "Created at", value = f"{ctx.guild.created_at}")
embed.set_footer(icon_url = f"{ctx.author.avatar_url}", text = f"Requested by {ctx.author.name}")
await ctx.send(embed=embed)
the event guild_subscriptions is set to False
I can't find any solution in discord.py documentation
这不是 事件。文档说它是创建 commands.Bot instance
时的参数,您可以 can 在客户端文档中找到它。如果向下滚动到该参数列表的底部,您会看到 guild_subscriptions(bool)
,这就是您要查找的内容。
要启用此功能,您只需将其添加到创建客户端的代码中:
client = commands.Bot(command_prefix=your_prefix, guild_subscriptions=True)
此外,从 Discord 1.5 开始,您现在需要传递正确的 Intents
,并且客户端的文档指出,如果您不想 guild.owner
,则需要启用 Intents.members
] 到 return None
,这也是导致您出现问题的原因。您还必须将这些意图作为参数传递,所以最终的结果看起来像这样:
# Configure intents (1.5.0)
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix=your_prefix, guild_subscriptions=True, intents=intents)
我在 discord.py 中遇到问题,下面的代码是 运行 完美的,但是 ctx.guild.owner
returns none,并且在文档中它说如果发生这种情况,事件 guild_subscriptions
设置为 False
,我如何将此事件设置为 True
以使其工作?我在 discord.py 文档中找不到任何解决方案,在 Google.
我的serverstats
命令的代码:
@commands.command(name="serverstats", aliases = ["serverinfo", "si", "ss", "check-stats", 'cs'])
async def serverstats(self, ctx: commands.Context):
embed = discord.Embed(
color = discord.Colour.orange(),
title = f"{ctx.guild.name}")
embed.set_thumbnail(url = f"{ctx.guild.icon_url}")
embed.add_field(name = "ID", value = f"{ctx.guild.id}")
embed.add_field(name = "Owner", value = f"{ctx.guild.owner}")
embed.add_field(name = "Region", value = f"{ctx.guild.region}")
embed.add_field(name = "Member Count", value = f"{ctx.guild.member_count}")
embed.add_field(name = "Created at", value = f"{ctx.guild.created_at}")
embed.set_footer(icon_url = f"{ctx.author.avatar_url}", text = f"Requested by {ctx.author.name}")
await ctx.send(embed=embed)
the event guild_subscriptions is set to False
I can't find any solution in discord.py documentation
这不是 事件。文档说它是创建 commands.Bot instance
时的参数,您可以 can 在客户端文档中找到它。如果向下滚动到该参数列表的底部,您会看到 guild_subscriptions(bool)
,这就是您要查找的内容。
要启用此功能,您只需将其添加到创建客户端的代码中:
client = commands.Bot(command_prefix=your_prefix, guild_subscriptions=True)
此外,从 Discord 1.5 开始,您现在需要传递正确的 Intents
,并且客户端的文档指出,如果您不想 guild.owner
,则需要启用 Intents.members
] 到 return None
,这也是导致您出现问题的原因。您还必须将这些意图作为参数传递,所以最终的结果看起来像这样:
# Configure intents (1.5.0)
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix=your_prefix, guild_subscriptions=True, intents=intents)