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
-- Require the Discordia library | |
local discordia = require("discordia") | |
-- Create a new bot client | |
local client = discordia.Client() | |
-- Require the config.lua file that contains the bot's prefix, token, and owner ID | |
local config = require("config") | |
-- Require the cogmanager.lua file that contains the code for loading and managing cogs | |
local cogmanager = require("cogmanager") | |
-- Load the cogs from the cogs folder using the loadCogs function |
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 |
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
-- Require the http library | |
local http = require('http') | |
-- Require the json library | |
local json = require('json') | |
-- Define a joke object | |
local joke = {} | |
-- Define a function to register the commands | |
function joke:registerCommands(client, slash) |
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 help object | |
local help = {} | |
-- Define a function to register the commands | |
function help:registerCommands(client, slash) | |
-- Define a slash command for help | |
slash:registerCommand('help', 'Get the list of commands', function(interaction) | |
-- Get the list of commands from the slash object | |
local commands = slash:getCommands() | |
-- Create a table to store the command names and descriptions |
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 an echo object | |
local echo = {} | |
-- Define a function to register the commands | |
function echo:registerCommands(client, slash) | |
-- Define a slash command for echo | |
slash:registerCommand('echo', 'Repeat a message', function(interaction) | |
-- Get the message from the interaction | |
local message = interaction.data.options[1].value | |
-- Reply with the message |
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 dotenv object | |
local dotenv = {} | |
-- Define a function to read a file and return its contents as a string | |
local function readFile(filename) | |
-- Open the file in read mode | |
local file = io.open(filename, 'r') | |
-- Check if the file exists | |
if not file then | |
-- Return nil and an error message |
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
-- Require the discordia library | |
local discordia = require('discordia') | |
-- Create a new class called CogManager | |
local CogManager = discordia.class('CogManager') | |
-- Define a constructor for the CogManager class | |
function CogManager:__init(__dirname) | |
-- Set the __dirname property to the argument | |
self.__dirname = __dirname | |
-- Create a table to store the cogs | |
self.cogs = {} |