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
|
||||
|
||||
function getnick(str, guild)
|
||||
local b = str:gsub("<@",""):gsub(">","")
|
||||
local user = guild:getMember(b)
|
||||
if user.nickname == nil then
|
||||
return user.name
|
||||
if guild ~= nil then
|
||||
local b = str:gsub("<@",""):gsub(">","")
|
||||
local user = guild:getMember(b)
|
||||
if user.nickname == nil then
|
||||
return user.name
|
||||
else
|
||||
return user.nickname
|
||||
end
|
||||
else
|
||||
return user.nickname
|
||||
local b = str:gsub("<@",""):gsub(">","")
|
||||
local user = client:getUser(b)
|
||||
return user.name
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Reference in a new issue