Fix bug that causes some commands to crash when executed in DM

This commit is contained in:
abbie 2022-11-04 17:03:05 +00:00
parent 607b1c02bb
commit f7d23d620e
No known key found for this signature in database
GPG key ID: A575D2415E5E5B6D

16
bot.lua
View file

@ -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