ManuelMaccou | Mosaic
ManuelMaccou | Mosaic
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 8/1/2023 in #djs-questions
getting partials for reactions when only ID is guaranteed
I just saw this in the d.js docs
WARNING Partial data is only ever guaranteed to contain an ID! Do not assume any property or method to work when dealing with a partial structure!
How for partial reactions, how do we make that work when regular emojis dont have an ID (unless I'm mistaken about that)
11 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 6/5/2023 in #djs-questions
How to completely removing an emoji, not just the reactions
In my app, the bot automatically adds different emoji reactions when a user creates a message. Afte a certain amount of time, I want that emoji removed. Not just the reactions, but the entire emoji. So far, I've only been able to figure out how to remove the reactions, which result in the default reaction count of 1, but the emoji is still there. Is there a way to remove the emoji entirely? Thanks all
5 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 6/2/2023 in #djs-questions
Stuck trying to create a map to track votes on messages
I'm trying to allow user to upvote/downvote messages using reactions, as well remove their previous vote. I'm using a map and a map of maps to do this. The problem is that when a user reacts to a message, the map "userMessageVotes" updates correctly, but the map of maps does not. userMessageVotes - A map of a users votes per message messageVotes - A map of maps that has all votes from all users in a message.
const messageVotes = new Map();

if (currentEmoji === '👍' || currentEmoji === '👎') {
console.log(`Reaction is 👍 or 👎`);
messageUserVotes.set(user.id, currentEmoji);
messageVotes.set(message.id, messageUserVotes);
console.log(`Updated vote for user ${user.id}: ${reaction.emoji.name}`);

console.log(`New messageUserVotes map for message ${message.id}: ${JSON.stringify(Array.from(messageUserVotes.entries()))}`);
console.log(`New messageVotes map for message ${message.id}: ${JSON.stringify(Array.from(messageVotes.entries()))}`);

} else {
console.log(`Reaction is not 👍 or 👎`);
}

if (currentEmoji === '👍' || currentEmoji === '👎') {
// Check if the opposite reaction exists
const oppositeEmoji = currentEmoji === '👍' ? '👎' : '👍';
const oppositeReaction = message.reactions.cache.find(r => r.emoji.name === oppositeEmoji);

// If the opposite reaction exists, remove it
if (oppositeReaction) {
await oppositeReaction.users.remove(user.id);
}

// Get previous vote
const previousVote = messageUserVotes.get(user.id) || null;
console.log(`Previous vote for user ${user.id}: ${previousVote}`);

const data = {...
const messageVotes = new Map();

if (currentEmoji === '👍' || currentEmoji === '👎') {
console.log(`Reaction is 👍 or 👎`);
messageUserVotes.set(user.id, currentEmoji);
messageVotes.set(message.id, messageUserVotes);
console.log(`Updated vote for user ${user.id}: ${reaction.emoji.name}`);

console.log(`New messageUserVotes map for message ${message.id}: ${JSON.stringify(Array.from(messageUserVotes.entries()))}`);
console.log(`New messageVotes map for message ${message.id}: ${JSON.stringify(Array.from(messageVotes.entries()))}`);

} else {
console.log(`Reaction is not 👍 or 👎`);
}

if (currentEmoji === '👍' || currentEmoji === '👎') {
// Check if the opposite reaction exists
const oppositeEmoji = currentEmoji === '👍' ? '👎' : '👍';
const oppositeReaction = message.reactions.cache.find(r => r.emoji.name === oppositeEmoji);

// If the opposite reaction exists, remove it
if (oppositeReaction) {
await oppositeReaction.users.remove(user.id);
}

// Get previous vote
const previousVote = messageUserVotes.get(user.id) || null;
console.log(`Previous vote for user ${user.id}: ${previousVote}`);

const data = {...
2 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 5/31/2023 in #djs-questions
message.channel.parent undefined in forum channel?
I'm getting an error where message.channel.parent is undefined. My intention is to cross-check the forum channel in which a user posts to make sure it's an "allowed channel". Am I not using this correctly to identify the parent forum channel of a new thread?
13 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 4/23/2023 in #djs-questions
Trying to get the content from the parent message in a forum post
I feel a little silly asking this because it's probably obvious. In a forum channel, I'm trying to get the content of the first message that started the forum post. The name, or title, is easy with message.channel.name But I cant figure out how to get the content.
2 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 4/9/2023 in #djs-questions
Sending messages from a forum channel to database, but unable to grab the tags
Everything is going through to my database from Discord, but I cant figure out how to grab the tags and the tag IDs. I've tried a few things...with the help of our AI overlords...but still no luck. Below is the section of the code where I try to grab the tag id client.on('messageCreate', async (message) => { if (message.author.bot) return; let appliedTags = []; if (message.channel.type === "GUILD_FORUM") { if (message.thread) { appliedTags = message.channel.availableTags.filter(tag => message.thread.metadata.appliedTags.includes(tag.id)); } else { console.log("No "thread" property."); } }
31 replies
DIAdiscord.js - Imagine a boo! 👻
Created by ManuelMaccou | Mosaic on 4/8/2023 in #djs-questions
How to specify the ID of a forum channel?
I have an app that sends messages to a database if they are in the pre-approved channel. I'm using the code below. This works fine when the message comes from a regular channel, but not a forum channel. Should channel.id be something else for forum channels? if (allowedChannels.some(channel => channel.channel_id === message.channel.id))
5 replies