Skip to content

Commit

Permalink
Updated embed code
Browse files Browse the repository at this point in the history
  • Loading branch information
Struck713 committed Feb 23, 2024
1 parent 98af8a3 commit d61ebaa
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 287 deletions.
41 changes: 13 additions & 28 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { ActivityType, Client, Events, GatewayIntentBits } from "discord.js";
import { YOUTUBE, TOKEN } from '../config.json';
import { COMMANDS } from "./commands";
import { VoiceManager } from "./lib/voice";
import { youtube, TOKEN } from '../config.json';
import commands from "./commands";
import { StateManager } from "./lib/state";
import YTDlpWrap from "yt-dlp-wrap";
import { Embeds } from "./lib/utils/embeds";
import { PollManager } from "./commands/poll";
export const ytdl = new YTDlpWrap(YOUTUBE.BINARY);

export const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent ] });
export const voiceManager = new VoiceManager();
export const ytdl = new YTDlpWrap(youtube.binary_path);
export const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});

export const stateManager = new StateManager();
export const pollManager = new PollManager();

client.once(Events.ClientReady, async client => {
console.log(`Logged in as ${client.user.tag}`);
console.log(`| Registered ${COMMANDS.length} commands!`);
console.log(`| Voice Manager Status: ${voiceManager ? "ONLINE" : "OFFLINE"}`);

client.user.setPresence({
status: "idle",
activities: [
Expand All @@ -31,7 +34,7 @@ client.once(Events.ClientReady, async client => {

client.on(Events.InteractionCreate, async interaction => {
if (interaction.isChatInputCommand()) {
const command = COMMANDS.find(command => command.data.name === interaction.commandName);
const command = commands.find(command => command.data.name === interaction.commandName);
if (!command) {
await Embeds.error(interaction, "Something went terribly wrong! Contact the developer.");
return;
Expand All @@ -42,21 +45,3 @@ client.on(Events.InteractionCreate, async interaction => {
});

client.login(TOKEN);

// const REPLIES = [
// "https://media.discordapp.net/attachments/709446245516574860/1153875831857352784/gideobn_lala.gif",
// "https://media.discordapp.net/attachments/1072009407497515059/1150969108008017960/brett.gif",
// "https://images-ext-2.discordapp.net/external/nqpPlVXUTEYQzmBZuYAhWBNyCRaxTVQ_GT8cNjfQaCQ/https/media.tenor.com/GEuUa7wY5JwAAAPo/sad-speech-bubble.mp4",
// "https://media.discordapp.net/attachments/709446245516574860/1150672443426484246/maletic.gif",
// "https://images-ext-1.discordapp.net/external/zSnVZqNRKx3g9Rc4D1kc7Hl_p2Qs5uomscPH6p9lp2E/https/media.tenor.com/HrUh7_ReprYAAAPo/police-help-speech-bubble.mp4",
// "https://media.tenor.com/ESD9F3r4uXIAAAPo/bubble-text-owl-text-bubble.mp4",
// "https://media.discordapp.net/attachments/709446245516574860/1151728821150695464/fridge.gif?width=507&height=676"
// ]

// client.on(Events.MessageCreate, async message => {
// if (Math.random() < 0.03) {
// await message.reply({ files: [ REPLIES[Math.floor(Math.random() * REPLIES.length)] ]});
// return;
// }
// })

9 changes: 5 additions & 4 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { SlashCommandBuilder } from "discord.js";
import { Command, deploy } from "../lib/command";
import { Embeds } from "../lib/utils/embeds";
import { COMMANDS } from ".";
import commands from ".";

const MY_SNOWFLAKE = "140520164629151744";

export const Deploy: Command = {
data: new SlashCommandBuilder()
.setName('deploy')
.setDescription('Deploys slash commands for the bot.'),
execute: async (client, interaction) => {
execute: async (_, interaction) => {
if (interaction.user.id === MY_SNOWFLAKE) {
deploy();
await Embeds.send(interaction, embed => embed
await Embeds.create()
.setTitle("Deployed commands")
.setDescription(`${COMMANDS.length} commands have been deployed.`));
.setDescription(`${commands.length} commands have been deployed.`)
.send(interaction);
} else await Embeds.error(interaction, "You do not have permission to execute this command!");
},
}
7 changes: 4 additions & 3 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { SlashCommandBuilder } from "discord.js";
import { Command } from "../lib/command";
import { Embeds } from "../lib/utils/embeds";
import { COMMANDS } from ".";
import commands from ".";

export const Help: Command = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Lists all the available commands.'),
execute: async (client, interaction) => {
await Embeds.send(interaction, embed => embed
await Embeds.create()
.setTitle("Help")
.setDescription(`There's a lot I can do for you. Here is a list of the avaliable commands:`)
.addFields(COMMANDS.map(command => ({ name: `/${command.data.name}`, value: command.data.description, inline: true }))));
.addFields(commands.map(command => ({ name: `/${command.data.name}`, value: command.data.description, inline: true })))
.send(interaction);
},
}
4 changes: 2 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { Meme } from "./meme";
import { Help } from "./help";
import { Poll } from "./poll";
import { Oobinate } from "./oob";
import { Minecraft } from "./minecraft";

export const COMMANDS = [ Help, Play, Skip, Queue, Stop, Meme, Oobinate, Poll, Status, Deploy, Minecraft ];
const commands = [ Help, Play, Skip, Queue, Stop, Meme, Oobinate, Poll, Status, Deploy ];
export default commands;
41 changes: 0 additions & 41 deletions src/commands/minecraft.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/commands/oob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export const Oobinate: Command = {
.addStringOption(option => option.setName("text").setRequired(true).setDescription("The text to oobinate.")),
execute: async (client, interaction) => {
let text = interaction.options.get("text", true);
await Embeds.send(interaction, embed => embed
await Embeds.create()
.setTitle("Oobinator")
.setDescription(`
\`${(text.value as string).replace(/[aeiouAEIOU]/g, "oob")}\`
`));
`)
.send(interaction);
},
}
15 changes: 9 additions & 6 deletions src/commands/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ export const Poll: Command = {
}

pollManager.create(name as string, []);
await Embeds.send(interaction, embed => embed
await Embeds.create()
.setAuthor({ name: "Poll" })
.setTitle(name as string)
.setDescription("Poll has been created."));
.setDescription("Poll has been created.")
.send(interaction);
return;
}

Expand All @@ -74,10 +75,11 @@ export const Poll: Command = {

let { value: option } = interaction.options.get("option", true);
poll.push({ key: option as string, value: 0 });
await Embeds.send(interaction, embed => embed
await Embeds.create()
.setAuthor({ name: "Poll" })
.setTitle(name as string)
.setDescription(`Added option, \`${option}\`.`));
.setDescription(`Added option, \`${option}\`.`)
.send(interaction);
return;
}

Expand All @@ -88,10 +90,11 @@ export const Poll: Command = {
}

let fields = poll.map((pair, index) => ({ name: `${Text.NUMBERS[index + 1]} ${pair.key}`, value: Text.number(pair.value, "vote") }));
let message = await Embeds.send(interaction, embed => embed
let message = await Embeds.create()
.setAuthor({ name: "Poll" })
.setTitle(name as string)
.addFields(fields));
.addFields(fields)
.send(interaction);
await Promise.all(poll.map((_, index) => message.react(Text.NUMBERS[index + 1])));
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export const Status: Command = {
.setDescription('Shows the current status for the bot.'),
execute: async (client, interaction) => {
let sent = Date.now();
await Embeds.send(interaction, embed => embed
await Embeds.create()
.setTitle("Status")
.setDescription(`
Bot has a latency of \`${sent - interaction.createdTimestamp}ms\`.
Currently running version \`${Style.VERSION}\` using \`${Style.ENGINE_VERSION}\`.
${Style.NAME} has been online for \`${Time.latestTime(Date.now() - STARTUP_TIME)}\`.
`));
`)
.send(interaction);
},
}
Loading

0 comments on commit d61ebaa

Please sign in to comment.