jr
jr
DIAdiscord.js - Imagine an app
Created by jr on 1/5/2024 in #djs-questions
Spurious messageUpdate
I just observed a messageUpdate event emitted on a message from 2018 that doesn't show as edited. What can cause this other than an edit? There are no embeds to the message so it shouldn't be embed related. Can this event fire when there is no change?
14 replies
DIAdiscord.js - Imagine an app
Created by jr on 1/2/2024 in #djs-questions
Check timeouts that have been issued
Is there a way to get a list of timeouts for users on a guild similar to Guild.bans? My specific use case: I need to check if a timeout has been issued for a specific user even if they aren't in the server, which guild.members.fetch(...)..communicationDisabledUntil !== null doesn't work for.
11 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/7/2023 in #djs-questions
Send video as attachment from url
I'm trying to send a video as an attachment but I'm getting an error
{
url: 'https://cdn.discordapp.com/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4?ex=655a467e&is=6547d17e&hm=c2646af1ffc78e9d4e880e179582d5f2b9f0b8138bd5ed723cef8027789f98a2&',
proxyURL: 'https://media.discordapp.net/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4',
width: 480,
height: 854
}
{
url: 'https://cdn.discordapp.com/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4?ex=655a467e&is=6547d17e&hm=c2646af1ffc78e9d4e880e179582d5f2b9f0b8138bd5ed723cef8027789f98a2&',
proxyURL: 'https://media.discordapp.net/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4',
width: 480,
height: 854
}
TypeError: Cannot read properties of undefined (reading 'path')
TypeError: Cannot read properties of undefined (reading 'path')
What am I doing wrong? If I upload from my client itself I see an attachment object that looks like this
{
"contentType": "video/mp4",
"description": null,
"ephemeral": false,
"height": 854,
"id": "1171519663264505896",
"name": "395548916_313950368025649_163387286946890286_n.mp4",
"proxyURL": "https://media.discordapp.net/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"size": 596512,
"spoiler": false,
"url": "https://cdn.discordapp.com/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"width": 480
}
{
"contentType": "video/mp4",
"description": null,
"ephemeral": false,
"height": 854,
"id": "1171519663264505896",
"name": "395548916_313950368025649_163387286946890286_n.mp4",
"proxyURL": "https://media.discordapp.net/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"size": 596512,
"spoiler": false,
"url": "https://cdn.discordapp.com/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"width": 480
}
Which fields do I need to include?
13 replies
DIAdiscord.js - Imagine an app
Created by jr on 10/25/2023 in #djs-questions
Prevent link embeds while sending a message
How can I prevent link embeds while sending a message? I'd like to avoid <url> if possible since I'm working with user-controlled input. https://github.com/discordjs/discord.js/issues/7818 seems to suggest it's technically possible to surpress at send time rather than doing a followup suppressEmbeds call
7 replies
DIAdiscord.js - Imagine an app
Created by jr on 9/10/2023 in #djs-questions
detect kick
Is there an easy way I can detect when a guild member is kicked?
3 replies
DIAdiscord.js - Imagine an app
Created by jr on 9/4/2023 in #djs-questions
channel.messages.fetch is giving messages outside the after/before range
I am encountering an issue where
const messages = await channel.messages.fetch({
limit: 100,
cache: false,
after: earliest_snowflake,
before: latest_snowflake,
});
const messages = await channel.messages.fetch({
limit: 100,
cache: false,
after: earliest_snowflake,
before: latest_snowflake,
});
is giving messages outside the specified range. What could cause this? Is it a discordjs bug or a discord api bug?
5 replies
DIAdiscord.js - Imagine an app
Created by jr on 7/31/2023 in #djs-questions
Somehow getting forum posts from a completely unrelelated forum channel
I have a utility function to fetch threads from a forum channel
export async function fetch_all_threads_archive_count(forum: Discord.ForumChannel, count: number) {
const threads = new Discord.Collection([
...await fetch_active_threads(forum),
...await fetch_inactive_threads_count(forum, count)
]);
return threads;
}
export async function fetch_all_threads_archive_count(forum: Discord.ForumChannel, count: number) {
const threads = new Discord.Collection([
...await fetch_active_threads(forum),
...await fetch_inactive_threads_count(forum, count)
]);
return threads;
}
Somehow this utility is giving me a completely unrelated forum post though:
// ...
const threads = await fetch_all_threads_archive_count(forum, cleanup_limit);
M.debug("Cleaning up", threads.size, "threads in", forum.name);
for(const [ _, thread ] of threads) {
M.debug(thread.name, thread.parentId, forum.id, forum.name);
assert(thread.parentId && thread.parentId == forum.id);
...
}
// ...
const threads = await fetch_all_threads_archive_count(forum, cleanup_limit);
M.debug("Cleaning up", threads.size, "threads in", forum.name);
for(const [ _, thread ] of threads) {
M.debug(thread.name, thread.parentId, forum.id, forum.name);
assert(thread.parentId && thread.parentId == forum.id);
...
}
I'm getting an output of Git 1124619767542718524 1013107104678162544 forum-a. The thread "Git" is from a channel called resources, not forum-a. I have no idea how it got here. I have no idea why the parent id could be different. The functions the utility calls
export async function fetch_active_threads(forum: Discord.ForumChannel) {
const { threads } = await forum.threads.fetchActive();
return threads;
}

export async function fetch_inactive_threads_count(forum: Discord.ForumChannel, count: number) {
let before: string | undefined = undefined;
const thread_entries: [string, Discord.ThreadChannel][] = [];
while(true) {
const { threads, hasMore } = await forum.threads.fetchArchived({ before, limit: Math.min(count, 100) });
thread_entries.push(...threads);
// The type annotation is needed because of a typescript bug
// https://github.com/microsoft/TypeScript/issues/51115
const last: Discord.ThreadChannel = threads.last()!;
before = last.id;
count -= threads.size;
if(!hasMore || count <= 0) {
break;
}
}
return new Discord.Collection(thread_entries);
}
export async function fetch_active_threads(forum: Discord.ForumChannel) {
const { threads } = await forum.threads.fetchActive();
return threads;
}

export async function fetch_inactive_threads_count(forum: Discord.ForumChannel, count: number) {
let before: string | undefined = undefined;
const thread_entries: [string, Discord.ThreadChannel][] = [];
while(true) {
const { threads, hasMore } = await forum.threads.fetchArchived({ before, limit: Math.min(count, 100) });
thread_entries.push(...threads);
// The type annotation is needed because of a typescript bug
// https://github.com/microsoft/TypeScript/issues/51115
const last: Discord.ThreadChannel = threads.last()!;
before = last.id;
count -= threads.size;
if(!hasMore || count <= 0) {
break;
}
}
return new Discord.Collection(thread_entries);
}
What's happening?
5 replies
DIAdiscord.js - Imagine an app
Created by jr on 5/4/2023 in #djs-questions
Incorrect reaction.count
I'm getting a reaction.count of 1 after receiving a reaction add event despite the message having 17 of these reactions. What can I do to troubleshoot this? I'm calling on partial reactions when needed, though that's not the case here.
36 replies
DIAdiscord.js - Imagine an app
Created by jr on 4/29/2023 in #djs-questions
Easiest way to lock a channel
What's the easiest way to temporarily lock a channel so no users can send messages?
3 replies
DIAdiscord.js - Imagine an app
Created by jr on 4/17/2023 in #djs-questions
Expanding the message cache
Quick question: Will this create a cache of 5000 message per channel?
makeCache: Discord.Options.cacheWithLimits({
...Discord.Options.DefaultMakeCacheSettings,
MessageManager: 5000
})
makeCache: Discord.Options.cacheWithLimits({
...Discord.Options.DefaultMakeCacheSettings,
MessageManager: 5000
})
I'm running into an issue where message reactions aren't being seen because the messages are presumably falling out of the cache.
5 replies
DIAdiscord.js - Imagine an app
Created by jr on 4/10/2023 in #djs-questions
Sending a video embed
Is it possible to send a video embed as a bot?
10 replies
DIAdiscord.js - Imagine an app
Created by jr on 4/10/2023 in #djs-questions
Easiest way to check if an emoji is default or belongs to the server
20 replies
DIAdiscord.js - Imagine an app
Created by jr on 2/26/2023 in #djs-questions
Sending a text attachment
How can I upload and send a text attachment in discordjs?
6 replies
DIAdiscord.js - Imagine an app
Created by jr on 2/25/2023 in #djs-questions
RoleSelectMenuBuilder
How do I set the roles available in a RoleSelectMenuBuilder? There's no .setOptions method it seems
10 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/20/2022 in #djs-questions
Text inputs
Are text inputs only a thing for modals? I need both a select menu and a text input and it seems select menus can't go in modals and text inputs can't go in another interaction reply.
7 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/18/2022 in #djs-questions
Suppressing specific embeds
15 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/12/2022 in #djs-questions
Message embeds are empty for image link
I'm running into an issue where a user sends a image link and the bot sees the image has empty embes on message create. If the user re-sends the image link, the bot recognizes it has embes immediately on message create. What causes this? How do I address it?
3 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/11/2022 in #djs-questions
When can ChatInputCommandInteraction.channel be null?
When can ChatInputCommandInteraction.channel be null?
9 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/3/2022 in #djs-questions
Check if user has write permissions in channel
Is there an easy way to check if a user has write permissions for a channel?
7 replies
DIAdiscord.js - Imagine an app
Created by jr on 11/2/2022 in #djs-questions
Autocomplete is slow
Is there a way to make slash command autocomplete more responsive? Right now it's taking like a second for autocomplete results to pop up.
8 replies