From f7d23d620e6c11a52acd13cf640add6ad6f23f87 Mon Sep 17 00:00:00 2001 From: Celeste Date: Fri, 4 Nov 2022 17:03:05 +0000 Subject: [PATCH] Fix bug that causes some commands to crash when executed in DM --- bot.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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