Created
February 15, 2023 13:10
-
-
Save veeponym/a807840faa4e789e4ae7adb11cec77e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Define a ping object | |
local ping = {} | |
-- Define a function to register the commands | |
function ping:registerCommands(client, slash) | |
-- Define a slash command for ping | |
slash:registerCommand('ping', 'Get the bot latency', function(interaction) | |
-- Get the timestamp of the interaction | |
local timestamp = interaction.data.timestamp | |
-- Get the current time | |
local now = os.time() | |
-- Calculate the latency | |
local latency = now - timestamp | |
-- Reply with the latency | |
interaction:reply('Pong! The latency is ' .. latency .. ' seconds.') | |
end) | |
end | |
-- Define a function to unregister the commands | |
function ping:unregisterCommands(client, slash) | |
-- Unregister the slash command for ping | |
slash:unregisterCommand('ping') | |
end | |
-- Return the ping object | |
return ping |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment