Discord APIs
- Client Functions:
discord.Client()
: Creates a new Discord client.client.run(TOKEN)
: Connects the client to Discord using the provided token.client.logout()
: Logs the client out of Discord.client.get_channel(id)
: Retrieves a channel by ID.client.get_guild(id)
: Retrieves a guild by ID.
- Message Functions:
message.channel.send(content)
: Sends a message to the channel.message.delete()
: Deletes the message.message.author
: Returns the author of the message.message.content
: Retrieves the content of the message.
- Member Functions:
member.create_dm()
: Creates a direct message channel with the member.member.dm_channel.send(content)
: Sends a direct message to the member.member.guild
: Retrieves the guild that the member is part of.member.roles
: Returns the roles that the member has.
- Guild Functions:
guild.get_member(id)
: Retrieves a member of the guild by ID.guild.members
: Returns a list of all members in the guild.guild.channels
: Returns a list of channels in the guild.guild.text_channels
: Returns text channels in the guild.
- Role Functions:
role.members
: Returns a list of members who have the role.role.edit()
: Edits the role's settings.
- Embed Functions:
discord.Embed()
: Creates an embed object for sending rich content.embed.add_field()
: Adds a field to the embed.embed.set_image()
: Sets an image in the embed.
หรือน้องๆสามารถดู API function ต่างๆ ได้ในลิงค์นี้เพิ่มเติมได้ นอกเหนือจากตัวอย่างที่พี่ๆ ยกมาได้ที่
https://discordpy.readthedocs.io/en/stable/api.html#
https://gist.github.com/s1072489/be00a6534a8fb743ce561f6f634910fc