22-- This file is part of the "Not a Bot" application
33-- For conditions of distribution and use, see copyright notice in LICENSE
44
5- local Date = Discordia .Date
6-
75Module .Name = " userinfo"
86
9- -- We have to precede special chars with an \ to prevent discord from replacing them with the corresponding emoji :<color>_circle:
10- local discordStatus = { online = " \\ 🟢 Online" , dnd = " \\ 🔴 Do Not Disturb" , idle = " \\ 🟡 Idle" , offline = " \\ ⚪ Offline" }
7+
8+ -- We have to precede special chars with an \ to prevent discord
9+ -- from replacing them with the corresponding emoji :<color>_circle:
10+ local discordStatus = {
11+ online = " \\ 🟢 Online" , dnd = " \\ 🔴 Do Not Disturb" , idle = " \\ 🟡 Idle" , offline = " \\ ⚪ Offline"
12+ }
1113local DEFAULT_COLOR = 0 -- Default color value, 0 == black
1214local JOIN_ORDER_WINDOW = 7 -- Number of members to show in "Join order" field
15+ local Date = Discordia .Date
1316local intents = Discordia .enums .gatewayIntent
1417-- Privileged intent, must be checked before use
1518local has_guild_presences_intent = (bit .band (Bot .Client :getIntents (), intents .guildPresences ) ~= 0 )
1619
1720-- The highest role with color ~= black defines the color of the username
1821local function getMemberColor (sortedRoles )
19- for i , v in ipairs (sortedRoles ) do
22+ for _ , v in ipairs (sortedRoles ) do
2023 if v .color ~= DEFAULT_COLOR then
2124 return v .color
2225 end
@@ -47,11 +50,22 @@ local function buildMemberEmbed(member)
4750 if has_guild_presences_intent then
4851 local presence = discordStatus [member .status ]
4952 description =
50- string.format (" __`Fullname:`__ `%s`\n __`Nickname:`__ `%s`\n __`Presence:`__ %s\n __`Created at:`__ <t:%s:f>\n __`Joined at:`__ <t:%s:f>\n " ,
53+ string.format ([[
54+ __`Fullname:`__ `%s`
55+ __`Nickname:`__ `%s`
56+ __`Presence:`__ %s
57+ __`Created at:`__ <t:%s:f>
58+ __`Joined at:`__ <t:%s:f>
59+ ]] ,
5160 fullName , member .name , presence , createdAt , joinedAt )
5261 else
5362 description =
54- string.format (" __`Fullname:`__ `%s`\n __`Nickname:`__ `%s`\n __`Created at:`__ <t:%s:f>\n __`Joined at:`__ <t:%s:f>\n " ,
63+ string.format ([[
64+ __`Fullname:`__ `%s`
65+ __`Nickname:`__ `%s`
66+ __`Created at:`__ <t:%s:f>
67+ __`Joined at:`__ <t:%s:f>
68+ ]] ,
5569 fullName , member .name , createdAt , joinedAt )
5670 end
5771
@@ -62,7 +76,7 @@ local function buildMemberEmbed(member)
6276 table.sort (roles , function (a , b ) return a .position > b .position end )
6377
6478 local roleNames = {}
65- for k , v in pairs (roles ) do
79+ for _ , v in pairs (roles ) do
6680 table.insert (roleNames , string.format (" `%s`" , v .name ))
6781 end
6882
@@ -118,16 +132,19 @@ function Module:OnLoaded()
118132 return commandMessage :reply ({ embed = buildMemberEmbed (commandMessage .member ) })
119133 end
120134
135+ local targetMember , targetUser
136+ local err
121137 local guild = commandMessage .guild
122- local targetMember , err = Bot :DecodeMember (guild , targetUserId )
138+
139+ targetMember , err = Bot :DecodeMember (guild , targetUserId )
123140
124141 if targetMember then
125142 return commandMessage :reply ({ embed = buildMemberEmbed (targetMember ) })
126143 elseif err == " Invalid user id" then
127144 return commandMessage :reply (err )
128145 else
129146 -- Not a member of this guild, trying to get info of the user
130- local targetUser , err = Bot :DecodeUser (targetUserId )
147+ targetUser , err = Bot :DecodeUser (targetUserId )
131148
132149 if targetUser then
133150 return commandMessage :reply ({ embed = buildUserEmbed (targetUser ) })
0 commit comments