let's add a little bit of protection
This commit is contained in:
parent
c9bdd6a8b7
commit
ab5ed16c18
@ -94,6 +94,9 @@ local function Callback(Interaction, Command, Args)
|
|||||||
user_info = API:GetRobloxInfoFromDiscordId(user.id)
|
user_info = API:GetRobloxInfoFromDiscordId(user.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not user_info.id then
|
||||||
|
return error('stop doing that')
|
||||||
|
end
|
||||||
|
|
||||||
local description = user_info.description=='' and 'This user has no description' or user_info.description
|
local description = user_info.description=='' and 'This user has no description' or user_info.description
|
||||||
-- table.foreach(user_info,print)
|
-- table.foreach(user_info,print)
|
||||||
|
13
src/main.lua
13
src/main.lua
@ -21,24 +21,31 @@ Client:on('ready', function()
|
|||||||
UserCommandCollector:Publish(Client)
|
UserCommandCollector:Publish(Client)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local function RunCallback(Callback, Interaction, Command, Args)
|
||||||
|
local Success, Return = pcall(Callback, Interaction, Command, Args)
|
||||||
|
if not Success then
|
||||||
|
Interaction:reply('Error encountered when trying to run command: '..Return, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Client:on('slashCommand', function(Interaction, Command, Args)
|
Client:on('slashCommand', function(Interaction, Command, Args)
|
||||||
local SlashCommand = SlashCommandCollector:Get(Command.name)
|
local SlashCommand = SlashCommandCollector:Get(Command.name)
|
||||||
if SlashCommand then
|
if SlashCommand then
|
||||||
SlashCommand.Callback(Interaction, Command, Args)
|
RunCallback(SlashCommand.Callback, Interaction, Command, Args)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Client:on('messageCommand', function(Interaction, Command, Message)
|
Client:on('messageCommand', function(Interaction, Command, Message)
|
||||||
local MessageCommand = MessageCommandCollector:Get(Command.name)
|
local MessageCommand = MessageCommandCollector:Get(Command.name)
|
||||||
if MessageCommand then
|
if MessageCommand then
|
||||||
MessageCommand.Callback(Interaction, Command, Message)
|
RunCallback(MessageCommand.Callback, Interaction, Command, Message)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Client:on('userCommand', function(Interaction, Command, Member)
|
Client:on('userCommand', function(Interaction, Command, Member)
|
||||||
local UserCommand = UserCommandCollector:Get(Command.name)
|
local UserCommand = UserCommandCollector:Get(Command.name)
|
||||||
if UserCommand then
|
if UserCommand then
|
||||||
UserCommand.Callback(Interaction, Command, Member)
|
RunCallback(UserCommand.Callback, Interaction, Command, Member)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user