Abheek Dhawan
2 years ago
19 changed files with 1340 additions and 1085 deletions
@ -1,16 +1,18 @@ |
|||
import { SlashCommandBuilder } from '@discordjs/builders'; |
|||
import { MessageEmbed, CommandInteraction } from 'discord.js'; |
|||
import { SlashCommandBuilder } from "@discordjs/builders"; |
|||
import { MessageEmbed, CommandInteraction } from "discord.js"; |
|||
|
|||
export const data = new SlashCommandBuilder() |
|||
.setName('help') |
|||
.setDescription('Replies with a help message explaining what the bot can do'); |
|||
.setName("help") |
|||
.setDescription("Replies with a help message explaining what the bot can do"); |
|||
|
|||
export async function execute(interaction: CommandInteraction) { |
|||
await interaction.deferReply(); |
|||
await interaction.deferReply(); |
|||
|
|||
const helpEmbed = new MessageEmbed() |
|||
.setDescription('AwesomeSciBo has migrated to using slash commands! You can take a look at the different commands by typing `/` and clicking on the AwesomeSciBo icon.') |
|||
.setColor('#ffffff'); |
|||
.setDescription( |
|||
"AwesomeSciBo has migrated to using slash commands! You can take a look at the different commands by typing `/` and clicking on the AwesomeSciBo icon." |
|||
) |
|||
.setColor("#ffffff"); |
|||
interaction.followUp({ embeds: [helpEmbed] }); |
|||
} |
@ -1,16 +1,17 @@ |
|||
import * as db from '../helpers/db'; |
|||
import { mongoUri } from '../helpers/env'; |
|||
import log from '../helpers/log'; |
|||
import * as db from "../helpers/db"; |
|||
import { mongoUri } from "../helpers/env"; |
|||
import log from "../helpers/log"; |
|||
|
|||
export const name = 'ready'; |
|||
export const name = "ready"; |
|||
|
|||
export const once = true; |
|||
|
|||
export async function execute(client) { |
|||
await db.connect(mongoUri); |
|||
log({ logger: 'status', content: `Logged in as ${client.user.tag}!`, level: 'info' }); |
|||
client.user.setActivity( |
|||
'for /help', |
|||
{ type: 'WATCHING' }, |
|||
); |
|||
log({ |
|||
logger: "status", |
|||
content: `Logged in as ${client.user.tag}!`, |
|||
level: "info", |
|||
}); |
|||
client.user.setActivity("for /help", { type: "WATCHING" }); |
|||
} |
|||
|
@ -1,6 +1,7 @@ |
|||
import 'dotenv/config'; |
|||
import "dotenv/config"; |
|||
|
|||
export const clientId = process.env.CLIENT_ID || ''; |
|||
export const testingGuild = process.env.TESTING_GUILD || ''; |
|||
export const token = process.env.TOKEN || ''; |
|||
export const mongoUri = process.env.MONGO_URI = 'mongodb://mongo:27017/AWESOME'; |
|||
export const clientId = process.env.CLIENT_ID || ""; |
|||
export const testingGuild = process.env.TESTING_GUILD || ""; |
|||
export const token = process.env.TOKEN || ""; |
|||
export const mongoUri = (process.env.MONGO_URI = |
|||
"mongodb://mongo:27017/AWESOME"); |
|||
|
@ -1,87 +1,113 @@ |
|||
import { CommandInteraction, Message, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js'; |
|||
import { |
|||
CommandInteraction, |
|||
Message, |
|||
MessageActionRow, |
|||
MessageButton, |
|||
MessageEmbed, |
|||
} from "discord.js"; |
|||
|
|||
export async function paginateMessage(message: Message, embeds: MessageEmbed[]) { |
|||
export async function paginateMessage( |
|||
message: Message, |
|||
embeds: MessageEmbed[] |
|||
) { |
|||
let index = 0; |
|||
|
|||
const row = new MessageActionRow; |
|||
const row = new MessageActionRow(); |
|||
row.addComponents( |
|||
new MessageButton() |
|||
.setCustomId('paginator-left') |
|||
.setEmoji('868552005977788466') |
|||
.setStyle('SECONDARY'), |
|||
.setCustomId("paginator-left") |
|||
.setEmoji("868552005977788466") |
|||
.setStyle("SECONDARY"), |
|||
new MessageButton() |
|||
.setCustomId('paginator-right') |
|||
.setEmoji('868551772887711754') |
|||
.setStyle('SECONDARY') |
|||
.setCustomId("paginator-right") |
|||
.setEmoji("868551772887711754") |
|||
.setStyle("SECONDARY") |
|||
); |
|||
|
|||
await message.reply({ content: `Page 1 of ${embeds.length}:`, embeds: [embeds[index]], components: [row] }) |
|||
.then(async paginatorMessage => { |
|||
const filter = m => m.author.id === message.author.id; |
|||
await message |
|||
.reply({ |
|||
content: `Page 1 of ${embeds.length}:`, |
|||
embeds: [embeds[index]], |
|||
components: [row], |
|||
}) |
|||
.then(async (paginatorMessage) => { |
|||
const filter = (m) => m.author.id === message.author.id; |
|||
|
|||
const paginatorCollector = paginatorMessage.createMessageComponentCollector({ |
|||
componentType: 'BUTTON', |
|||
const paginatorCollector = |
|||
paginatorMessage.createMessageComponentCollector({ |
|||
componentType: "BUTTON", |
|||
filter: filter, |
|||
}); |
|||
|
|||
paginatorCollector.on('collect', async i => { |
|||
paginatorCollector.on("collect", async (i) => { |
|||
switch (i.customId) { |
|||
case 'paginator-left': |
|||
case "paginator-left": |
|||
index--; |
|||
if (index < 0) index = embeds.length - 1; |
|||
break; |
|||
case 'paginator-right': |
|||
case "paginator-right": |
|||
index++; |
|||
if (index > embeds.length - 1) index = 0; |
|||
break; |
|||
} |
|||
paginatorMessage.edit({ content: `Page ${index + 1} of ${embeds.length}:`, embeds: [embeds[index]] }); |
|||
paginatorMessage.edit({ |
|||
content: `Page ${index + 1} of ${embeds.length}:`, |
|||
embeds: [embeds[index]], |
|||
}); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
export async function paginateInteraction(interaction: CommandInteraction, embeds: MessageEmbed[]) { |
|||
export async function paginateInteraction( |
|||
interaction: CommandInteraction, |
|||
embeds: MessageEmbed[] |
|||
) { |
|||
let index = 0; |
|||
|
|||
const row = new MessageActionRow; |
|||
const row = new MessageActionRow(); |
|||
row.addComponents( |
|||
new MessageButton() |
|||
.setCustomId('paginator-left') |
|||
.setEmoji('868552005977788466') |
|||
.setStyle('SECONDARY'), |
|||
.setCustomId("paginator-left") |
|||
.setEmoji("868552005977788466") |
|||
.setStyle("SECONDARY"), |
|||
new MessageButton() |
|||
.setCustomId('paginator-right') |
|||
.setEmoji('868551772887711754') |
|||
.setStyle('SECONDARY') |
|||
.setCustomId("paginator-right") |
|||
.setEmoji("868551772887711754") |
|||
.setStyle("SECONDARY") |
|||
); |
|||
|
|||
await interaction.followUp({ |
|||
await interaction |
|||
.followUp({ |
|||
content: `Page 1 of ${embeds.length}:`, |
|||
embeds: [embeds[index]], |
|||
components: [row], |
|||
fetchReply: true, |
|||
}) |
|||
.then(async p => { |
|||
.then(async (p) => { |
|||
const paginatorMessage = p as Message; |
|||
const filter = i => i.user.id === interaction.user.id; |
|||
const filter = (i) => i.user.id === interaction.user.id; |
|||
|
|||
const paginatorCollector = paginatorMessage.createMessageComponentCollector({ |
|||
componentType: 'BUTTON', |
|||
const paginatorCollector = |
|||
paginatorMessage.createMessageComponentCollector({ |
|||
componentType: "BUTTON", |
|||
filter: filter, |
|||
}); |
|||
|
|||
paginatorCollector.on('collect', async i => { |
|||
paginatorCollector.on("collect", async (i) => { |
|||
switch (i.customId) { |
|||
case 'paginator-left': |
|||
case "paginator-left": |
|||
index--; |
|||
if (index < 0) index = embeds.length - 1; |
|||
break; |
|||
case 'paginator-right': |
|||
case "paginator-right": |
|||
index++; |
|||
if (index > embeds.length - 1) index = 0; |
|||
break; |
|||
} |
|||
await i.update({ content: `Page ${index + 1} of ${embeds.length}:`, embeds: [embeds[index]] }); |
|||
await i.update({ |
|||
content: `Page ${index + 1} of ${embeds.length}:`, |
|||
embeds: [embeds[index]], |
|||
}); |
|||
}); |
|||
}); |
|||
} |
Loading…
Reference in new issue