Tyranasaurus
Tyranasaurus
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 5/3/2024 in #djs-questions
'Unknown Integration'
No description
6 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 10/23/2023 in #djs-questions
Bot Direct Message Rate Limits/Quarantine
Hello, A few years ago I was working on a bot, and eventually decided I wanted to give all of its users a brief update about the bot so I tried sending each of them a DM at the same time. This resulted in my bot getting indefinitely quarantined. Now, I'm trying to use Discord as a notification system for a WebApp I've built, and I'm wondering if there is any way to determine what that quarantine/rate limit might look like? I can't seem to find any information online, but I really don't want my bot to get quarantined again. How do some of the bigger/well established bots that DM you not get quarantined? Like the ones that DM you every time you join a server or whatnot?
11 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 10/15/2023 in #djs-questions
Accessing values of an authorization request.
Hello - I've just made an OAuth request from discord and stored it in a requests object as follows:
export async function GET({ request, url }) {
console.log(request);
}
export async function GET({ request, url }) {
console.log(request);
}
The request object, when printed to the console, looks like this:
request Request {
[Symbol(realm)]: {
settingsObject: { baseUrl: undefined, origin: [Getter], policyContainer: [Object] }
},
etc...,
[Symbol(signal)]: AbortSignal { aborted: false },
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => [Object],
'connection' => [Object],
'sec-ch-ua' => [Object],
'sec-ch-ua-mobile' => [Object],
'sec-ch-ua-platform' => [Object],
'upgrade-insecure-requests' => [Object],
'user-agent' => [Object],
'accept' => [Object],
'sec-fetch-site' => [Object],
'sec-fetch-mode' => [Object],
'sec-fetch-user' => [Object],
'sec-fetch-dest' => [Object],
'accept-encoding' => [Object],
'accept-language' => [Object],
'cookie' => [Object]
},
[Symbol(headers map sorted)]: null
}
}
request Request {
[Symbol(realm)]: {
settingsObject: { baseUrl: undefined, origin: [Getter], policyContainer: [Object] }
},
etc...,
[Symbol(signal)]: AbortSignal { aborted: false },
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => [Object],
'connection' => [Object],
'sec-ch-ua' => [Object],
'sec-ch-ua-mobile' => [Object],
'sec-ch-ua-platform' => [Object],
'upgrade-insecure-requests' => [Object],
'user-agent' => [Object],
'accept' => [Object],
'sec-fetch-site' => [Object],
'sec-fetch-mode' => [Object],
'sec-fetch-user' => [Object],
'sec-fetch-dest' => [Object],
'accept-encoding' => [Object],
'accept-language' => [Object],
'cookie' => [Object]
},
[Symbol(headers map sorted)]: null
}
}
I need to access the object stored in the following path: request->[Symbol(headers)]->[Symbol(headers map)]->cookie. I managed to get console.log(request.headers) to print out the following, but I can't figure out how to get into the headers map object.
HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => "hostValue",
'connection' => "connectionValue",
etc.,
'cookie' => {
name: 'cookie',
value: 'someValueThatIHaveHidden'
}
},
[Symbol(headers map sorted)]: null
}
HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => "hostValue",
'connection' => "connectionValue",
etc.,
'cookie' => {
name: 'cookie',
value: 'someValueThatIHaveHidden'
}
},
[Symbol(headers map sorted)]: null
}
Any help would be much appreciated!
4 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 9/11/2023 in #djs-questions
member is of type 'unknown'
I'm building a command in typescript, and have the following:
const members = await interaction.guild.members.fetch();
console.log(members);
for (const [id, member] of Object.entries(members)) {
console.log(member.roles);
}
const members = await interaction.guild.members.fetch();
console.log(members);
for (const [id, member] of Object.entries(members)) {
console.log(member.roles);
}
The first console.log(members) works fine but the second line gives me the error member is of type 'unknown', how do I fix this/move forward?
7 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 4/23/2023 in #djs-questions
Remove user from all private threads
As described - I have the user added to a private thread and want a way to remove the user from their private threads, without necessarily knowing what private threads they are currently added in.
12 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 4/22/2023 in #djs-questions
How to tell if I'm hitting Discord's rate limit
As asked - my code is hanging up on creating a role after having created a few roles already - is this normal behavior for rate limiting? I would have thought it would throw an error if I were being limited. The same piece of code sometimes works to create a role and othertime just hangs - its like the await promise is never returning when I call guild.roles.create
4 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 4/21/2023 in #djs-questions
Get number of channels in category
Hello, pretty simple, trying to do the above. if I have the CategoryChannel object, I've tried CategoryChannel.children.size, but this doesn't work. I've messed around with a couple of other solutions that didn't work either.
5 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 4/7/2023 in #djs-questions
Adding an entire role to a private thread
Hello - I am making a private thread, and I know how to add a particular user to it - is there anyway to add an entire role? If not, how can I efficiently unpack the users with the role and add them to the thread?
17 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 4/7/2023 in #djs-questions
Deleting all channels in a category
The following code gives the error 'channel.children.forEach is not a function. I have verified that channel.children is a CategoryChannelChildManager object
channel.children.forEach(async (voice_channel) => {
await voice_channel.delete();
});
channel.children.forEach(async (voice_channel) => {
await voice_channel.delete();
});
3 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 4/7/2023 in #djs-questions
Fetching and Deleting all threads within a channel
Hello. I have the ID of a tech channel, and I want to delete all threads (active or archived) that are children of that channel. Can't seem to figure out what the syntax to make this work is.
7 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 12/29/2022 in #djs-questions
How can I make an application webhook (webhook type 3).
I'm trying to build a webhook that has buttons, which requires a webhook of type 3 (https://discord.com/developers/docs/resources/webhook#execute-webhook). I only know how to make webhooks of type 1 using the Discord UI - how can I make one of type 3?
5 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/18/2022 in #djs-questions
Fetching a Member by id.
Pretty simple, trying to figure out how to get a member in a specific guild by the member's id (member.id). Ideally, I would like to use fetch, the cache hasn't been super reliable for me.
18 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/17/2022 in #djs-questions
On VoiceStateUpdate determine if change was not caused by the member themselves
Hello! I'm using VoiceStateUpdate listeners to determine when members are joining or leaving voice channels. However, I want to ignore cases where the user was moved or disconnected by another member or bot. Is there a way for me to do this?
3 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/13/2022 in #djs-questions
Getting Number of Members with particular role
Hello! As described above, I'm trying to determine the number of members in my server of a particular role. I've got the following code, but for some reason .members keeps returning an empty map.
const staff_role_count = oldMember.guild.roles.cache.get(roles.Staff).members.size;
const staff_count_channel = client.channels.cache.get(
voice_channels.Staff_Count
);
staff_count_channel.edit({ name: "Staff: " + staff_role_count });
const staff_role_count = oldMember.guild.roles.cache.get(roles.Staff).members.size;
const staff_count_channel = client.channels.cache.get(
voice_channels.Staff_Count
);
staff_count_channel.edit({ name: "Staff: " + staff_role_count });
Do you know what's going wrong?
Console.log(oldMember.guild.roles.cache.get(roles.Staff).members)
Console.log(oldMember.guild.roles.cache.get(roles.Staff).members)
results in an empty map, and the value of staff_role_count gets set to 0
4 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/12/2022 in #djs-questions
rate limit prevention
Hello - I'm building a 'breakout rooms' bot that will simultaneously mass move 100+ users from one voice channel to a bunch of other voice channels, and I'm worried about running into Discord's rate limits. I also have the unfortunate problem of not being able to test this bot with the 100+ users until the day of the event I'm using it for. Anyways, I was reading at https://discord.com/developers/docs/topics/rate-limits, where it says 'Because rate limits depend on a variety of factors and are subject to change, rate limits should not be hard coded into your app. Instead, your app should parse response headers to prevent hitting the limit, and to respond accordingly in case you do.' I was wondering how I can receive and parse said response headers in discord.js - the documentation doesn't appear to have any references to this that I could find. Thanks in advance!
14 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/12/2022 in #djs-questions
GuildMemberAdd Not Workingg
Hello! I'm attempting to assign an 'unverified' role whenever someone new joins my server, but the bot doesn't appear to be registering new members - I never receive the console log - do I have some sort of error?
client.on(Events.GuildMemberAdd, async (member) => {
console.log("Hello");
if (member.user.bot) {
return;
}

await member.edit({
roles: [roles.Unverified],
});
});
client.on(Events.GuildMemberAdd, async (member) => {
console.log("Hello");
if (member.user.bot) {
return;
}

await member.edit({
roles: [roles.Unverified],
});
});
8 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/12/2022 in #djs-questions
setTimeout with an async function
Hello, I'm currently trying to use a setTimeout function to wait for an interaction from the user, and if it doesn't receive it in time, remove the interactable components from the message. So, I have something like
async removeComponents(message) {
await message.edit({content: "Timeout"})
}

async someOtherFunction() {
const timeout = setTimeout(removeComponents(message), 120000)

async removeComponents(message) {
await message.edit({content: "Timeout"})
}

async someOtherFunction() {
const timeout = setTimeout(removeComponents(message), 120000)

This, however, gives me the error that
The "callback" argument must be of type function. Received an instance of Promise
The "callback" argument must be of type function. Received an instance of Promise
If I instead do
const timeout = setTimeout(await removeComponents, 120000)
const timeout = setTimeout(await removeComponents, 120000)
I receive
The "callback" argument must be of type function. Received a undefined.
The "callback" argument must be of type function. Received a undefined.
What can I do to get around this / what have other people done when trying to remove interactions after a certain amount of time?
9 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/7/2022 in #djs-questions
inconsistent 'interaction not found' errors
Hello! I have a series of interactions, and I can't consistently reproduce this bug at the same spot, but inconsistently I'll get interaction not found errors and I'm not exactly sure what's causing them. Anyone know or can help me fix?
20 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 11/7/2022 in #djs-questions
Disabling Button while Modal is in use
Hello! I'm trying to create a button that pops up a modal - however, I'm trying to make it so only one user can have the modal open at a time. So, if user A presses the button, the button will show up as disabled to all other users until user A either submits or cancels the modal, upon which the buttons will re-enable I'm able to re-enable the buttons on user submit, currently, but I'm struggling to figure out how to do it if User A cancels the modal and doesn't submit anything.
9 replies
DIAdiscord.js - Imagine an app
Created by Tyranasaurus on 10/27/2022 in #djs-questions
Ability to not respond to slash commands without an error popping up?
Hello - I was wondering if there was a way to mark an interaction as complete without actually having anything pop up to the user? I have a series of buttons that modify an embed (a pagination menu) and it is quite inconvenient if every time they click a button an ephemeral reply pops up.
13 replies