diff --git a/bot.lua b/bot.lua index bc34d8e..0b18b4c 100644 --- a/bot.lua +++ b/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