def channelinfo(self, ctx, *, channel: discord.TextChannel=None):
"""Display information about a text channel.
Defaults to the current channel.
* channel - Optional argument. A specific channel to get information about."""
# If channel is None, then it is set to ctx.channel.
channel = channel or ctx.channel
embed = discord.Embed(title=f"{channel.name}")
try:
embed.description = channel.topic
except AttributeError:
pass
embed.add_field(name="Channel ID", value=channel.id)
try:
embed.add_field(name="Guild", value=channel.guild.name)
except AttributeError:
pass
embed.add_field(name="Members", value=len(channel.members))
embed.add_field(name="Created at", value=channel.created_at.ctime())
if channel.is_nsfw():
embed.set_footer(text="NSFW content is allowed for this channel.")
await ctx.send(embed=embed)
评论列表
文章目录