-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathexample.lua
151 lines (127 loc) · 5.09 KB
/
example.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
-- IMPORTANT:
-- For use in other resources, you will need to use:
-- exports.Badger_Discord_API:<function>
--
-- For example:
-- exports.Badger_Discord_API:GetRoleIdFromRoleName("roleName")
RegisterCommand('testResource', function(source, args, rawCommand)
local user = source; -- The user
-- function GetRoleIdFromRoleName(name)
-- Returns nil if not found
-- Returns Discord Role ID if found
-- Usage:
local roleName = "Founder"; -- Change this to an existing role name on your Discord server
local roleID = GetRoleIdFromRoleName(roleName);
print("[Badger_Perms Example] The roleID for (" .. roleName .. ") is: " .. tostring(roleID));
-- function IsDiscordEmailVerified(user)
-- Returns false if not found
-- Returns true if verified
-- Usage:
local isVerified = IsDiscordEmailVerified(user);
print("[Badger_Perms Example] Player " .. GetPlayerName(user) .. " has Discord email verified?: " .. tostring(isVerified));
-- function GetDiscordEmail(user)
-- Returns nil if not found
-- Returns Email if found
-- Usage:
local emailAddr = GetDiscordEmail(user);
print("[Badger_Perms Example] Player " .. GetPlayerName(user) .. " has Discord email address: " .. tostring(emailAddr));
-- function GetDiscordName(user)
-- Returns nil if not found
-- Returns Discord name if found
-- Usage:
local name = GetDiscordName(user);
print("[Badger_Perms Example] Player " .. GetPlayerName(user) .. " has Discord name: " .. tostring(name));
-- function GetGuildIcon()
-- Returns nil if not found
-- Returns URL if found
-- Usage:
local icon_URL = GetGuildIcon();
print("[Badger_Perms Example] Guild icon URL is: " .. tostring(icon_URL));
-- function GetGuildSplash()
-- Returns nil if not found
-- Returns URL if found
-- Usage:
local splash_URL = GetGuildSplash();
print("[Badger_Perms Example] Guild splash URL is: " .. tostring(splash_URL));
-- function GetGuildName()
-- Returns nil if not found
-- Returns name if found
-- Usage:
local guildName = GetGuildName();
print("[Badger_Perms Example] Guild name is: " .. tostring(guildName));
-- function GetGuildDescription()
-- Returns nil if not found
-- Returns description if found
-- Usage:
local guildDesc = GetGuildDescription();
print("[Badger_Perms Example] Guild description is: " .. tostring(guildDesc));
-- function GetGuildMemberCount()
-- Returns nil if not found
-- Returns member count if found
-- Usage:
local guildMemCount = GetGuildMemberCount();
print("[Badger_Perms Example] Guild member count is: " .. tostring(guildMemCount));
-- function GetGuildOnlineMemberCount()
-- Returns nil if not found
-- Returns description if found
-- Usage:
local onlineMemCount = GetGuildOnlineMemberCount();
print("[Badger_Perms Example] Guild online member count is: " .. tostring(onlineMemCount));
-- function GetDiscordAvatar(user)
-- Returns nil if not found
-- Returns URL if found
-- Usage:
local avatar = GetDiscordAvatar(user);
print("[Badger_Perms Example] Player " .. GetPlayerName(user) .. " has Discord avatar: " .. tostring(avatar));
-- function GetDiscordNickname(user)
-- Returns nil if not found
-- Returns nickname if found
-- Usage:
local nickname = GetDiscordNickname(user);
print("[Badger_Perms Example] Player " .. GetPlayerName(user) .. " has Discord nickname: " .. tostring(nickname));
-- function GetGuildRoleList()
-- Returns nil if not found
-- Returns associative array if found
-- Usage:
local roles = GetGuildRoleList();
for roleName, roleID in pairs(roles) do
print(roleName .. " === " .. roleID);
end
-- function GetDiscordRoles(user)
-- Returns nil if not found
-- Returns array if found
-- Usage:
local roles = GetDiscordRoles(user)
for i = 1, #roles do
print(roles[i]);
end
-- function CheckEqual(role1, role2)
-- Returns false if not equal
-- Returns true if equal
-- Usage:
local isRolesEqual = CheckEqual("Founder", 597446100206616596);
local isRolesEqual2 = CheckEqual("FounderRef", "Founder"); -- Refer to config.lua file, this is basically checking if FounderRef in the config is
-- equal to the Founder role's ID
-- function SetNickname(user, nickname)
-- Returns error code 403 if the user is higher than the bot
-- Usage:
SetNickname(user, "🦡Badger", "Set nickname")
SetNickname(user, "", "Reset nickname")
-- function AddRole(user, roleId, reason)
-- Returns error code 403 if the user is higher than the bot
-- Usage:
AddRole(user, "1038448129709723670", "Add role")
-- function SetRoles(user, roleList, reason)
-- Returns error code 403 if the user is higher than the bot
-- Usage:
SetRoles(user, { "1038448129709723670" }, "Set roles")
-- function RemoveRole(user, roleId, reason)
-- Returns error code 403 if the user is higher than the bot
-- Usage:
RemoveRole(user, "1038448129709723670", "Remove role")
-- function ChangeDiscordVoice(user, voiceID)
-- Returns error code 400 if voice channel ID is incorrect
-- Usage:
ChangeDiscordVoice(user, 123456789123456789)
ChangeDiscordVoice(user, 123456789123456789, "Moved "..GetPlayerName(user).." to the admin channel")
end)