Snapper
Snapper
DIAdiscord.js - Imagine an app
Created by Snapper on 2/23/2024 in #djs-questions
message collector filter not working as intended
Hello, I'm trying to build a message collector that only collects specific numbers or phrases for a bot for a game community. In doing so, I'm not sure why this logic isn't working. Is there another logic I can use or a change to the syntax I can use that will help me get the reply to be edited at the bottom of my code?
const collectorFilter = (m) => m.user.id === interaction.user.id && m.content.includes(
1 || "FC" || "fc" || "FC Items" || "Fc Items" || "fc items" ||
2 || "dow" || "DoW" || "Disciple of War" || "disciple of war" || "War" || "war" ||
3 || "dol" || "DoL" || "Disciple of Land" || "disciple of land" || "Land" || "land" ||
4 || "Glamour Items" || "glamour items" || "Glam" || "glam" || "Glamour" || "glamour" ||
5 || "Housing Items" || "housing items" || "Housing" || "housing" || "House" || "house");
const collector = interaction.channel.createMessageCollector({ filter: collectorFilter, time: 15_000, max: 1});

collector.on('collect', m => {
if (m.contains( 1 || "FC" || "fc" || "FC Items" || "Fc Items" || "fc items")){
interaction.editReply({
content: "collector is working"
});
}
});

collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
const collectorFilter = (m) => m.user.id === interaction.user.id && m.content.includes(
1 || "FC" || "fc" || "FC Items" || "Fc Items" || "fc items" ||
2 || "dow" || "DoW" || "Disciple of War" || "disciple of war" || "War" || "war" ||
3 || "dol" || "DoL" || "Disciple of Land" || "disciple of land" || "Land" || "land" ||
4 || "Glamour Items" || "glamour items" || "Glam" || "glam" || "Glamour" || "glamour" ||
5 || "Housing Items" || "housing items" || "Housing" || "housing" || "House" || "house");
const collector = interaction.channel.createMessageCollector({ filter: collectorFilter, time: 15_000, max: 1});

collector.on('collect', m => {
if (m.contains( 1 || "FC" || "fc" || "FC Items" || "Fc Items" || "fc items")){
interaction.editReply({
content: "collector is working"
});
}
});

collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
15 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 11/19/2023 in #djs-questions
is there a way to enable slash commands to work from the discord overlay?
Like could I potentially have a message filter in an event that captures someone typing it from the overlay and then triggers a command for that person? I'm just not entirely sure how overlay messages are treated in discord.
7 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 11/9/2023 in #djs-questions
unable to access cache for member.roles
for some reason the if(!member.roles.cache.find('')) is coming back as undefined. What did I do wrong?
const reactions = await message.reactions.cache.get("❤️");
const members = await reactions.users.fetch();
let updatedMembers = 0;

await members.forEach((member) => {
if(!member.roles.cache.find("1171954559611047986" && member.kickable === 'true')){
member.roles.add("1171954559611047986");
console.log(`Assigned the rule verified role to ${member.user.name}`);
updatedMembers++;
} else {
console.log(`${member.user.name} is already verified or no longer in the server.`);
}
});
const reactions = await message.reactions.cache.get("❤️");
const members = await reactions.users.fetch();
let updatedMembers = 0;

await members.forEach((member) => {
if(!member.roles.cache.find("1171954559611047986" && member.kickable === 'true')){
member.roles.add("1171954559611047986");
console.log(`Assigned the rule verified role to ${member.user.name}`);
updatedMembers++;
} else {
console.log(`${member.user.name} is already verified or no longer in the server.`);
}
});
12 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 11/9/2023 in #djs-questions
client.channels.cache.get(channelId) returning undefined
Hello, I'm unsure why a specific message is returning undefined from a channel. Could use another set of eyes since I've been staring for so long.
const { Client, Events, GatewayIntentBits, Partials, ReactionManager, SlashCommandBuilder,} = require("discord.js");
const clientInstance = require("../../bot.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("verify")
.setDescription("assign and remove the verify role for the rules."),


async execute(interaction, client) {
const botMessage = await interaction.deferReply({
fetchReply: true,
});


const message = client.channels.cache
.get(1103869557849997403)
.messages.cache.get(1164272120994463744); //message id;
console.log(message);


if (!message) {
console.error('Message not found.');
return;
}
const { Client, Events, GatewayIntentBits, Partials, ReactionManager, SlashCommandBuilder,} = require("discord.js");
const clientInstance = require("../../bot.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("verify")
.setDescription("assign and remove the verify role for the rules."),


async execute(interaction, client) {
const botMessage = await interaction.deferReply({
fetchReply: true,
});


const message = client.channels.cache
.get(1103869557849997403)
.messages.cache.get(1164272120994463744); //message id;
console.log(message);


if (!message) {
console.error('Message not found.');
return;
}
35 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/15/2023 in #djs-questions
my reaction isn't being passed from one script to another.
Passing
client.on(Events.MessageReactionAdd, async (reaction, member) => {
let r = reaction;
let rM = reaction.member;
ruleVerify.execute(client);
});
client.on(Events.MessageReactionAdd, async (reaction, member) => {
let r = reaction;
let rM = reaction.member;
ruleVerify.execute(client);
});
Retrieving
async execute(client) {
let reaction = client.r;
//let member = sessionStorage.getItem("reactionInstanceMember");
console.log(reaction);
}
async execute(client) {
let reaction = client.r;
//let member = sessionStorage.getItem("reactionInstanceMember");
console.log(reaction);
}
12 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/10/2023 in #djs-questions
if one user is already using a slash command, other users are unable to create their own instances
I made a quiz bot recently and when more than 1 person is trying to use the commands at a time the bot responds with "this command failed" when they try to enter the loop for the quiz. Is there some reason it doesn't support multiple instances?
5 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/9/2023 in #djs-questions
Filter not picking up when a user interacts with a static message
module.exports = {
name: 'ruleVerify',

async execute(client){

const rulesMessage = client.guild.channels.message.cache.id('1116202445916348497')
const message = await message.reply({
content: `React here!`,
fetchReply: true,
});

const emoji = client.emojis.cache.find(
(emoji) => (emoji.name = "💜")
);

message.react(emoji);

const filter = (reaction) => {
return reaction.emoji.name == '💜'}

const collector = rulesMessage.createReactionCollector({filter});

collector.on('collect', (reaction, member) => {
console.log(`${member} has been verified from clicking ${reaction}`);

})



},
};
module.exports = {
name: 'ruleVerify',

async execute(client){

const rulesMessage = client.guild.channels.message.cache.id('1116202445916348497')
const message = await message.reply({
content: `React here!`,
fetchReply: true,
});

const emoji = client.emojis.cache.find(
(emoji) => (emoji.name = "💜")
);

message.react(emoji);

const filter = (reaction) => {
return reaction.emoji.name == '💜'}

const collector = rulesMessage.createReactionCollector({filter});

collector.on('collect', (reaction, member) => {
console.log(`${member} has been verified from clicking ${reaction}`);

})



},
};
7 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/7/2023 in #djs-questions
is there a way to make discord wait for a second button input after the first update?
Also update the buttons in the action row...
20 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/7/2023 in #djs-questions
Reply failing on button interaction, getting no errors
22 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/6/2023 in #djs-questions
logic building question (flow chart included):
6 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/6/2023 in #djs-questions
Not sure why my embed is failing.
Hello! I have an embed that I'm putting together and I'm getting a TypeError that I'm not quite sure I understand. Could someone help me understand what the error is trying to say?
TypeError: (intermediate value).setTitle(...).setDescription(...).setColor(...).setThumbnail(...).setTimestamp(...).addComponents is not a function
at Object.execute (C:\Users\Owner\Desktop\BartleBot\src\commands\tools\quiz.js:31:8)
at Object.execute (C:\Users\Owner\Desktop\BartleBot\src\events\client\interactionCreate.js:12:27)
at Client.<anonymous> (C:\Users\Owner\Desktop\BartleBot\src\functions\handlers\handleEvents.js:15:67)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
at WebSocketManager.emit (C:\Users\Owner\Desktop\BartleBot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.<anonymous> (C:\Users\Owner\Desktop\BartleBot\node_modules\@discordjs\ws\dist\index.js:1103:51)
TypeError: (intermediate value).setTitle(...).setDescription(...).setColor(...).setThumbnail(...).setTimestamp(...).addComponents is not a function
at Object.execute (C:\Users\Owner\Desktop\BartleBot\src\commands\tools\quiz.js:31:8)
at Object.execute (C:\Users\Owner\Desktop\BartleBot\src\events\client\interactionCreate.js:12:27)
at Client.<anonymous> (C:\Users\Owner\Desktop\BartleBot\src\functions\handlers\handleEvents.js:15:67)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (C:\Users\Owner\Desktop\BartleBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
at WebSocketManager.emit (C:\Users\Owner\Desktop\BartleBot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.<anonymous> (C:\Users\Owner\Desktop\BartleBot\node_modules\@discordjs\ws\dist\index.js:1103:51)
22 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/5/2023 in #djs-questions
Need help sending an echo to a channel without it being a reply to a slash command.
The title says it all. I want the reply to be sent as an ephemeral message to the user in the channel they performed the slash command, and I want the message to echo into another text channel. I've been at this all day and haven't had any luck. Here's what I've got code wise at the moment but I've tried just about everything I can find.
23 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/4/2023 in #djs-questions
Is there a way to hide this part of the slash command
13 replies
DIAdiscord.js - Imagine an app
Created by Snapper on 6/4/2023 in #djs-questions
Bot becomes unresponsive after executing a slash command
Hello! I'm building a discord bot and I've got it functional up to the point of the slash command handler working for one iteration. After any user sends a slash command the bot becomes unresponsive I'm not sure where in my Logic the issue may be, so I'm going to post the relevant code blocks and maybe someone might be able to help me understand where I went wrong 🙂
38 replies