Wxrnin
Wxrnin
Explore posts from servers
SIASapphire - Imagine a framework
Created by Wxrnin on 4/3/2024 in #sapphire-support
Listeners and Index.js
Hello, I basically made a Giveaway System, but I have a code that needs to be in index.js and 1 that needs to be as event, but right now I am clueless as where to put the index.js to put it into perspective of normal discord.js framework, 1 code ness to be in the inde.js and the other in the events folder but I don't know where to put these code using the sapphire framework. When I put the code that's supposed to be in my index.js file, i get this error:
/home/container/src/index.js:22
client.giveawayManager = new GiveawaysManager(client, {
^
TypeError: GiveawaysManager is not a constructor
at Object.<anonymous> (/home/container/src/index.js:22:26)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.12.0
/home/container/src/index.js:22
client.giveawayManager = new GiveawaysManager(client, {
^
TypeError: GiveawaysManager is not a constructor
at Object.<anonymous> (/home/container/src/index.js:22:26)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.12.0
The code that's supposed to go into index.js: https://sourceb.in/ANt8LGRFiM The code that's supposed to go into the events folder aka listener: https://sourceb.in/GD3Cbxbg5y Here is my current index.js and listener code with the giveaway code included:
Index.js - https://sourceb.in/9NXZs3iBfO Event - https://sourceb.in/bODqOfaqBX
13 replies
SIASapphire - Imagine a framework
Created by Wxrnin on 3/25/2024 in #discordjs-support
Invalid Token Error
How do I fix this error:
const invalidToken = new DiscordjsError(ErrorCodes.TokenInvalid);
^
Error [TokenInvalid]: An invalid token was provided.
at WebSocketManager.connect (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:136:26)
at BeemoClient.login (/home/container/node_modules/discord.js/src/client/Client.js:228:21)
at BeemoClient.login (/home/container/node_modules/@sapphire/framework/dist/cjs/lib/SapphireClient.cjs:82:31) {
code: 'TokenInvalid'
}
const invalidToken = new DiscordjsError(ErrorCodes.TokenInvalid);
^
Error [TokenInvalid]: An invalid token was provided.
at WebSocketManager.connect (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:136:26)
at BeemoClient.login (/home/container/node_modules/discord.js/src/client/Client.js:228:21)
at BeemoClient.login (/home/container/node_modules/@sapphire/framework/dist/cjs/lib/SapphireClient.cjs:82:31) {
code: 'TokenInvalid'
}
I have already reset the token, I have already console logged the typeof token which is a string and I have consoled log the token itself which returns with the correct token.
11 replies
SIASapphire - Imagine a framework
Created by Wxrnin on 3/22/2024 in #sapphire-support
User Install (The new update)
Hello, I am attempting to make my JavaScript d.js Discord Bot work with the new User Install feature (The new update). To do this, I need to modify the handleCommands, but this is only found with the normal discord.js framework, which leads me wondering how to add the system to make the new UserInstall feature work with my sapphire framework. If anyone could assist, I would be grateful!
16 replies
SIASapphire - Imagine a framework
Created by Wxrnin on 3/11/2024 in #sapphire-support
Paginated Message not working
When I run this code, it says "This interaction failed" without any error.
const { PaginatedMessage } = require('@sapphire/discord.js-utilities');
const BeemoCommand = require('../../../lib/structures/commands/BeemoCommand');
const { EmbedBuilder } = require('discord.js');
const { color, emojis } = require('../../../config');
const Guild = require('../../../lib/schemas/blacklist');
const { PermissionLevels } = require('../../../lib/types/Enums');

class UserCommand extends BeemoCommand {
constructor(context, options) {
super(context, {
...options,
permissionLevel: PermissionLevels.BotOwner,
description: 'A command that uses paginated messages.',
});
}

/**
* @param {BeemoCommand.Registry} registry
*/
registerApplicationCommands(registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName('blacklist-list')
.setDescription(this.description))
}

async messageRun(interaction) {
const blacklistedGuilds = await Guild.find();

if (blacklistedGuilds.length === 0) {
return await interaction.reply(`${emojis.custom.fail} No servers have been **detected** in my blacklist!`);
}

const paginatedMessage = new PaginatedMessage({
template: new EmbedBuilder()
.setColor(`${color.default}`)
.setFooter({ text: 'Page 1/1' })
});

blacklistedGuilds.forEach(guild => {
paginatedMessage.addPageEmbed(embed =>
embed
.setTitle(`Blacklisted Server: ${guild.guildId}`)
.setDescription(`Reason: ${guild.reason}`)
);
});

await paginatedMessage.run(interaction);
}
}

module.exports = {
UserCommand
};
const { PaginatedMessage } = require('@sapphire/discord.js-utilities');
const BeemoCommand = require('../../../lib/structures/commands/BeemoCommand');
const { EmbedBuilder } = require('discord.js');
const { color, emojis } = require('../../../config');
const Guild = require('../../../lib/schemas/blacklist');
const { PermissionLevels } = require('../../../lib/types/Enums');

class UserCommand extends BeemoCommand {
constructor(context, options) {
super(context, {
...options,
permissionLevel: PermissionLevels.BotOwner,
description: 'A command that uses paginated messages.',
});
}

/**
* @param {BeemoCommand.Registry} registry
*/
registerApplicationCommands(registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName('blacklist-list')
.setDescription(this.description))
}

async messageRun(interaction) {
const blacklistedGuilds = await Guild.find();

if (blacklistedGuilds.length === 0) {
return await interaction.reply(`${emojis.custom.fail} No servers have been **detected** in my blacklist!`);
}

const paginatedMessage = new PaginatedMessage({
template: new EmbedBuilder()
.setColor(`${color.default}`)
.setFooter({ text: 'Page 1/1' })
});

blacklistedGuilds.forEach(guild => {
paginatedMessage.addPageEmbed(embed =>
embed
.setTitle(`Blacklisted Server: ${guild.guildId}`)
.setDescription(`Reason: ${guild.reason}`)
);
});

await paginatedMessage.run(interaction);
}
}

module.exports = {
UserCommand
};
What I am trying to do: Look, what I'm trying to do is to make it so there is more than 1 server in an embed and buttons that goes left and right. Here is an example of how the embeds should look like: 🚫 Blacklisted Servers (1st Server ID) (Reason of Blacklist) ----------------------- (2nd Server ID) (Reason of Blacklist) and so on.
6 replies
DIdiscord.js - Imagine ❄
Created by Wxrnin on 3/11/2024 in #djs-questions
"This Interaction Failed" Error
The code functions as followed: Once I do /blacklist-server add, the owner of the blacklisted server will receive an DM where then click a button and apply to be unblacklisted. The issues lies when the owner tries to click the button, it sends an "This interaction failed" error. Here is my code:
const { Listener } = require('@sapphire/framework');
const {
Events,
ModalBuilder,
TextInputBuilder,
TextInputStyle,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder
} = require("discord.js");
const { color, emojis } = require('../../config');
const Guild = require('../../schemas/blacklistSchema');

class UserEvent extends Listener {

constructor(context, options = {}) {
super(context, {
...options
});
}

async run(interaction, client) {
if (interaction.customId !== "ban_appeal_modal") {
if (interaction.customId === "ban_appeal") {
const modal = new ModalBuilder()
.setCustomId('ban_appeal_modal')
.setTitle('Blacklist Appeal');
const Q1 = new TextInputBuilder()
.setCustomId('question_1')
.setLabel("Your ID")
.setStyle(TextInputStyle.Short);
const Q2 = new TextInputBuilder()
.setCustomId('question_2')
.setLabel("What was the reason for your blacklist?")
.setStyle(TextInputStyle.Short);
const Q3 = new TextInputBuilder()
.setCustomId('question_3')
.setLabel("Why do you think you should be unblacklisted?")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder().addComponents(Q1);
const secondActionRow = new ActionRowBuilder().addComponents(Q2);
const thirdActionRow = new ActionRowBuilder().addComponents(Q3);

modal.addComponents(firstActionRow, secondActionRow, thirdActionRow);

await interaction.showModal(modal);
}
if (interaction.customId === "blacklist_appeal_accept") {
const ownerId = interaction.guild.ownerId;
const owner = await client.users.fetch(ownerId);
const currentDate = new Date().toLocaleDateString();
await owner.send(`${emojis.custom.tada} Your blacklist appeal has been **accepted** on **${currentDate}**!`);
await interaction.reply({
content: `${emojis.custom.success} You have successfully **accepted** ${owner}'s blacklist appeal on **${currentDate}**!`,
ephemeral: true
});
}
if (interaction.customId === "blacklist_appeal_deny") {
const ownerId = interaction.guild.ownerId;
const owner = await client.users.fetch(ownerId);
const currentDate = new Date().toLocaleDateString();
await owner.send(`${emojis.custom.fail} Your blacklist appeal has been **denied** on **${currentDate}**!`);
await interaction.reply({
content: `${emojis.custom.success} You have successfully **denied** ${owner}'s blacklist appeal on **${currentDate}**!`,
ephemeral: true
});
}
}
}
};

module.exports = {
UserEvent
};
const { Listener } = require('@sapphire/framework');
const {
Events,
ModalBuilder,
TextInputBuilder,
TextInputStyle,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder
} = require("discord.js");
const { color, emojis } = require('../../config');
const Guild = require('../../schemas/blacklistSchema');

class UserEvent extends Listener {

constructor(context, options = {}) {
super(context, {
...options
});
}

async run(interaction, client) {
if (interaction.customId !== "ban_appeal_modal") {
if (interaction.customId === "ban_appeal") {
const modal = new ModalBuilder()
.setCustomId('ban_appeal_modal')
.setTitle('Blacklist Appeal');
const Q1 = new TextInputBuilder()
.setCustomId('question_1')
.setLabel("Your ID")
.setStyle(TextInputStyle.Short);
const Q2 = new TextInputBuilder()
.setCustomId('question_2')
.setLabel("What was the reason for your blacklist?")
.setStyle(TextInputStyle.Short);
const Q3 = new TextInputBuilder()
.setCustomId('question_3')
.setLabel("Why do you think you should be unblacklisted?")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new ActionRowBuilder().addComponents(Q1);
const secondActionRow = new ActionRowBuilder().addComponents(Q2);
const thirdActionRow = new ActionRowBuilder().addComponents(Q3);

modal.addComponents(firstActionRow, secondActionRow, thirdActionRow);

await interaction.showModal(modal);
}
if (interaction.customId === "blacklist_appeal_accept") {
const ownerId = interaction.guild.ownerId;
const owner = await client.users.fetch(ownerId);
const currentDate = new Date().toLocaleDateString();
await owner.send(`${emojis.custom.tada} Your blacklist appeal has been **accepted** on **${currentDate}**!`);
await interaction.reply({
content: `${emojis.custom.success} You have successfully **accepted** ${owner}'s blacklist appeal on **${currentDate}**!`,
ephemeral: true
});
}
if (interaction.customId === "blacklist_appeal_deny") {
const ownerId = interaction.guild.ownerId;
const owner = await client.users.fetch(ownerId);
const currentDate = new Date().toLocaleDateString();
await owner.send(`${emojis.custom.fail} Your blacklist appeal has been **denied** on **${currentDate}**!`);
await interaction.reply({
content: `${emojis.custom.success} You have successfully **denied** ${owner}'s blacklist appeal on **${currentDate}**!`,
ephemeral: true
});
}
}
}
};

module.exports = {
UserEvent
};
10 replies