Skip to content

Instantly share code, notes, and snippets.

View veeponym's full-sized avatar

Veepo veeponym

View GitHub Profile
@veeponym
veeponym / bot.lua
Last active February 15, 2023 15:17
-- 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
-- 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
-- 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)
-- 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
-- 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
-- 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
-- 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 = {}