The Discord API uses numbers to represent certain data types. For convenience, these are enumerated in Discord as special read-only tables, found in the main Discordia module. All available enumerations are listed at the end of this page.
local discordia = require('discordia')
local enums = discordia.enums
Enumerations (enums) can be accessed like a regular Lua table, but they cannot be modified. This is completely optional, but it is generally easier to use and read enumerations than it is to use and read plain numbers. For example, given a text channel object, the following are logically equivalent:
if channel.type == 0 then
print('This is a text channel!')
end
if channel.type == enums.channelType.text then
print('This is a text channel!')
end
print(enums.verificationLevel.low) -- 1
Additionally, enumerations work in reverse. If you have the number, but you want to recall the human-readable version, simply call the enum; it will return a string if the enumeration is valid.
print(enums.channelType(channel.type)) -- 'text'
print(enums.verificationLevel(1)) -- 'low'
If necessary, custom enumerations can be written using the enum
constructor:
local fruit = enums.enum {
apple = 0,
orange = 1,
banana = 2,
cherry = 3,
}
The enumerations are designed to be compatible with the Discord API. They are not necessarily unique to Discordia.
name |
value |
blurple |
0 |
gray |
1 |
green |
2 |
orange |
3 |
red |
4 |
name |
value |
text |
0 |
private |
1 |
voice |
2 |
group |
3 |
category |
4 |
name |
value |
default |
0 |
recipientAdd |
1 |
recipientRemove |
2 |
call |
3 |
channelNameChange |
4 |
channelIconchange |
5 |
pinnedMessage |
6 |
memberJoin |
7 |
name |
value |
none |
0 |
friend |
1 |
blocked |
2 |
pendingIncoming |
3 |
pendingOutgoing |
4 |
name |
value |
default |
0 |
streaming |
1 |
listening |
2 |
name |
value |
default |
0 |
streaming |
1 |
name |
value |
none |
0 |
low |
1 |
medium |
2 |
high |
3 |
veryHigh |
4 |
name |
value |
none |
0 |
medium |
1 |
high |
2 |
name |
value |
allMessages |
0 |
onlyMentions |
1 |
name |
value |
createInstantInvite |
0x00000001 |
kickMembers |
0x00000002 |
banMembers |
0x00000004 |
administrator |
0x00000008 |
manageChannels |
0x00000010 |
manageGuild |
0x00000020 |
addReactions |
0x00000040 |
viewAuditLog |
0x00000080 |
readMessages |
0x00000400 |
sendMessages |
0x00000800 |
sendTextToSpeech |
0x00001000 |
manageMessages |
0x00002000 |
embedLinks |
0x00004000 |
attachFiles |
0x00008000 |
readMessageHistory |
0x00010000 |
mentionEveryone |
0x00020000 |
useExternalEmojis |
0x00040000 |
connect |
0x00100000 |
speak |
0x00200000 |
muteMembers |
0x00400000 |
deafenMembers |
0x00800000 |
moveMembers |
0x01000000 |
useVoiceActivity |
0x02000000 |
changeNickname |
0x04000000 |
manageNicknames |
0x08000000 |
manageRoles |
0x10000000 |
manageWebhooks |
0x20000000 |
manageEmojis |
0x40000000 |
name |
value |
guildUpdate |
1 |
channelCreate |
10 |
channelUpdate |
11 |
channelDelete |
12 |
channelOverwriteCreate |
13 |
channelOverwriteUpdate |
14 |
channelOverwriteDelete |
15 |
memberKick |
20 |
memberPrune |
21 |
memberBanAdd |
22 |
memberBanRemove |
23 |
memberUpdate |
24 |
memberRoleUpdate |
25 |
roleCreate |
30 |
roleUpdate |
31 |
roleDelete |
32 |
inviteCreate |
40 |
inviteUpdate |
41 |
inviteDelete |
42 |
webhookCreate |
50 |
webhookUpdate |
51 |
webhookDelete |
52 |
emojiCreate |
60 |
emojiUpdate |
61 |
emojiDelete |
62 |
messageDelete |
72 |
These enumerations are not necessarily relevant to the Discord API, but are used in Discordia in other ways.
name |
value |
none |
0 |
error |
1 |
warning |
2 |
info |
3 |
debug |
4 |