1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

discord.pyで管理者を判定する

Posted at

discordでは、サーバを作った人が管理者になります
その管理者かどうかを判定する方法です

@client.event
async def on_message(message):
# テキストチャンネルのみ処理    
    if message.channel.type != discord.ChannelType.text:
        return

# 管理者のときのみエコーする
    if message.author.guild_permissions.administrator:
        await message.channel.send(message.contents)

一応注意として、message.authorがMemberでないといけません
例えば、プライベートチャンネル(DM)だと、Memberではないので、
上の例ではテキストチャンネル限定としています

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?