adam
adam
DIAdiscord.js - Imagine an app
Created by adam on 10/27/2023 in #djs-questions
Mass adding of roles
When running a mass adding command, does discord take care of the rate limit, i.e., gives it in batches, or does that have to be done by the bot?
9 replies
DIAdiscord.js - Imagine an app
Created by adam on 9/1/2023 in #djs-questions
How to cache and receive User Object
Hello, I'm currently trying to cache users by using
let test = client.users.cache
let test = client.users.cache
and i log it by:
test.forEach((ID, USER) => {
console.log(USER);
});
test.forEach((ID, USER) => {
console.log(USER);
});
How can i get the User object back instead of IDs?
10 replies
DIAdiscord.js - Imagine an app
Created by adam on 8/30/2023 in #djs-questions
Creating a attachment with a link
Hello! Currently i have a link that is cdn.discordapp.com in a webp format, how can i use attachment builder to upload it as a file? link =
let img = randomMember?.avatarURL({ size: 1024, extension: "webp" })
let img = randomMember?.avatarURL({ size: 1024, extension: "webp" })
20 replies
DIAdiscord.js - Imagine an app
Created by adam on 8/14/2023 in #djs-questions
Getting User Guild Avatar/Banner
Hi I'd like to know how can i get the user's avatar and banner in the current guild Currently I get the user info from
let currentUser =
message.mentions.users.size > 0
|| message.mentions.users.first()
let currentUser =
message.mentions.users.size > 0
|| message.mentions.users.first()
12 replies
DIAdiscord.js - Imagine an app
Created by adam on 8/2/2023 in #djs-questions
If user has higher role than bot
Currently i have this code:
let targetMember =
message.mentions.members?.first()
let targetMember =
message.mentions.members?.first()
how can i check if the bot has a lower role than targetMember?
10 replies
DIAdiscord.js - Imagine an app
Created by adam on 7/25/2023 in #djs-questions
Upgarding ChannelType from djsv13 to djsv14
Hi! Can i know whats the new replacement for (its currently in djsv13):
console.log(member.guild.channels.cache.filter((c) => c.type === "TEXT_CHANNEL"))
console.log(member.guild.channels.cache.filter((c) => c.type === "TEXT_CHANNEL"))
in djs v14?
4 replies
DIAdiscord.js - Imagine an app
Created by adam on 7/23/2023 in #djs-questions
TypeError: isJSONEncodable is not a function
Hi! I keep getting this error when i mention the bot:
TypeError: isJSONEncodable is not a function
at C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:200:9
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:199:36)
at TextChannel.send (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:169:32)
at Message.reply (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\Message.js:803:25)
at module.exports (C:\Users\Adamh\Documents\marlean\events\client\messageCreate.js:88:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
<rejected> TypeError: isJSONEncodable is not a function
at C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:200:9
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:199:36)
at TextChannel.send (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:169:32)
at Message.reply (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\Message.js:803:25)
at module.exports (C:\Users\Adamh\Documents\marlean\events\client\messageCreate.js:88:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
TypeError: isJSONEncodable is not a function
at C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:200:9
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:199:36)
at TextChannel.send (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:169:32)
at Message.reply (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\Message.js:803:25)
at module.exports (C:\Users\Adamh\Documents\marlean\events\client\messageCreate.js:88:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
<rejected> TypeError: isJSONEncodable is not a function
at C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:200:9
at Array.map (<anonymous>)
at MessagePayload.resolveBody (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\MessagePayload.js:199:36)
at TextChannel.send (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:169:32)
at Message.reply (C:\Users\Adamh\Documents\marlean\node_modules\discord.js\src\structures\Message.js:803:25)
at module.exports (C:\Users\Adamh\Documents\marlean\events\client\messageCreate.js:88:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
6 replies
DIAdiscord.js - Imagine an app
Created by adam on 6/27/2023 in #djs-questions
[MONGOOSE/MONGODB] How can I get a specific users schema?
Hello! I've been coding for the past few hours and can't exactly seem to figure this out so I've been trying to get a specific users totalMessages (from schema) at a specific date, heres my code (this is being run inside my command file, level/messages.js):
const totalMessagesData = UserDocument.totalMessages
const todayMessages = UserModel.find({
createdAt: {
$gte: today.toDate(),
$lte: moment(today).endOf('day').toDate()
}
})

console.log(todayMessages.model.schema.paths.totalMessages.validators)
const totalMessagesData = UserDocument.totalMessages
const todayMessages = UserModel.find({
createdAt: {
$gte: today.toDate(),
$lte: moment(today).endOf('day').toDate()
}
})

console.log(todayMessages.model.schema.paths.totalMessages.validators)
My totalMessages in schema is a number value, and I've been trying to get it but all I get in console from:
console.log(todayMessages.model.schema.paths.totalMessages.validators)
console.log(todayMessages.model.schema.paths.totalMessages.validators)
is:
{
validator: [Function (anonymous)],
message: 'Path `{PATH}` is required.',
type: 'required'
}
]
{
validator: [Function (anonymous)],
message: 'Path `{PATH}` is required.',
type: 'required'
}
]
Would appeciate any help 🙂
4 replies