forked from threeoh6000/joltik
Fix bug that causes some commands to crash when executed in DM
This commit is contained in:
parent
607b1c02bb
commit
f7d23d620e
1 changed files with 11 additions and 5 deletions
16
bot.lua
16
bot.lua
|
@ -11,12 +11,18 @@ string.startswith = function(self, str)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getnick(str, guild)
|
function getnick(str, guild)
|
||||||
local b = str:gsub("<@",""):gsub(">","")
|
if guild ~= nil then
|
||||||
local user = guild:getMember(b)
|
local b = str:gsub("<@",""):gsub(">","")
|
||||||
if user.nickname == nil then
|
local user = guild:getMember(b)
|
||||||
return user.name
|
if user.nickname == nil then
|
||||||
|
return user.name
|
||||||
|
else
|
||||||
|
return user.nickname
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return user.nickname
|
local b = str:gsub("<@",""):gsub(">","")
|
||||||
|
local user = client:getUser(b)
|
||||||
|
return user.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in a new issue