Mara
Mara
DIAdiscord.js - Imagine an app
Created by Mara on 6/22/2024 in #djs-questions
Forum tags - Create a new tag if not exists
I try to create a new tags in a forum if the tag exists:
const availableTags: GuildForumTagData[] = allTags.map((tag) => {
return {
id: tag.id,
moderated: tag.moderated,
name: tag.name,
emoji: tag.emoji,
};
});
availableTags.push({
name: "Dice Roll",
emoji: { id: null, name: "๐Ÿชก" },
});
await forum.setAvailableTags(availableTags);
return availableTags.find(
(tag) => tag.name === "Dice Roll" && tag.emoji?.name === "๐Ÿชก"
) as GuildForumTagData;
const availableTags: GuildForumTagData[] = allTags.map((tag) => {
return {
id: tag.id,
moderated: tag.moderated,
name: tag.name,
emoji: tag.emoji,
};
});
availableTags.push({
name: "Dice Roll",
emoji: { id: null, name: "๐Ÿชก" },
});
await forum.setAvailableTags(availableTags);
return availableTags.find(
(tag) => tag.name === "Dice Roll" && tag.emoji?.name === "๐Ÿชก"
) as GuildForumTagData;
But it seems that the absence of id leads to an error:
Invalid Form Body
applied_tags[0][BASE_TYPE_REQUIRED]: This field is required
Invalid Form Body
applied_tags[0][BASE_TYPE_REQUIRED]: This field is required
But I don't know how to set an ID when creating a new tags?
3 replies
DIAdiscord.js - Imagine an app
Created by Mara on 4/19/2024 in #djs-questions
[Question] How long is a file stored?
My bot send an attachment (simple JSON files) and stock the ID of the message (+channel obviously). I download the attachment and parse it when needed. But with the changement discord have with attachment, I want to know how long it lives on the server before being deleted. I don't mean about the links expiring, but the attachment itself (as I don't use the attachment URL).
6 replies
DIAdiscord.js - Imagine an app
Created by Mara on 4/14/2024 in #djs-questions
Fetch a message by using the url
I know we can get a message with channel and message ID, but maybe it exists a methods to get from url directly, instead of parsing the URL (like regex) and get channel and after the message ? (It's a general question but in case of : - discord.js : discord.js@14.14.1 - node : v18.18.0 )
7 replies
DIAdiscord.js - Imagine an app
Created by Mara on 3/5/2024 in #djs-questions
Modal โ€” Pagination
Hi! To construct my bot, I wanted to use modals allowing user reply. But my number of fields is more than 5. It's is possible to construct multiple modals with pagination or simply the button "validate" open the second modal? (I can count easily the number of futur fields and cut by 5) I can't use a specific slash commands here (as the argument are user defined) so I have the choice between modal pagination or waiting a reply for the user (using a more generic slash commands) I think the second pretty long vs a modal, that's why I ask.
6 replies
DIAdiscord.js - Imagine an app
Created by Mara on 7/21/2023 in #djs-questions
Embed: Wrong image in iconURL
Hello! I'm with Typescript. I generate my image using my GitHub repository, so I just need to push to it and use https://raw.githubusercontent.com/${GITHUB}/master/images The image has been successfully pushed (for example, see : https://raw.githubusercontent.com/lisandra-dev/velum-bot/master/images/meteo/moon/waxing-crescent.png) But, my bot continue to load/display the old version of the image, as I changed the image previously. How cache image works in discord ? How can I fix that ? I use a link like that:
const moon = {
"Waxing Crescent" : `${IMAGE_LINK}/meteo/moon/waxing-crescent.png`, //๐ŸŒ’
"First Quarter" : `${IMAGE_LINK}/meteo/moon/first-quarter.png`, //๐ŸŒ“
"New" : `${IMAGE_LINK}/meteo/moon/new-moon.png`, //๐ŸŒ‘
"Waxing Gibbous" : `${IMAGE_LINK}/meteo/moon/waxing-gibbous.png`, //๐ŸŒ”
"Full" : `${IMAGE_LINK}/meteo/moon/full-moon.png`, //๐ŸŒ•
"Waning Gibbous" : `${IMAGE_LINK}/meteo/moon/waning-gibbous.png`, //๐ŸŒ–
"Last Quarter" : `${IMAGE_LINK}/meteo/moon/third-quarter.png`, //๐ŸŒ—
"Waning Crescent" : `${IMAGE_LINK}/meteo/moon/waning-crescent.png`, //๐ŸŒ˜
};

let embed = new EmbedBuilder()
.setThumbnail(icon)
.setDescription(capitalize(data.weather.description))
.setAuthor({
name: `${city} ยท ${main}`,
iconURL: `${moon[Moon.lunarPhase()]}` as string,
})
const moon = {
"Waxing Crescent" : `${IMAGE_LINK}/meteo/moon/waxing-crescent.png`, //๐ŸŒ’
"First Quarter" : `${IMAGE_LINK}/meteo/moon/first-quarter.png`, //๐ŸŒ“
"New" : `${IMAGE_LINK}/meteo/moon/new-moon.png`, //๐ŸŒ‘
"Waxing Gibbous" : `${IMAGE_LINK}/meteo/moon/waxing-gibbous.png`, //๐ŸŒ”
"Full" : `${IMAGE_LINK}/meteo/moon/full-moon.png`, //๐ŸŒ•
"Waning Gibbous" : `${IMAGE_LINK}/meteo/moon/waning-gibbous.png`, //๐ŸŒ–
"Last Quarter" : `${IMAGE_LINK}/meteo/moon/third-quarter.png`, //๐ŸŒ—
"Waning Crescent" : `${IMAGE_LINK}/meteo/moon/waning-crescent.png`, //๐ŸŒ˜
};

let embed = new EmbedBuilder()
.setThumbnail(icon)
.setDescription(capitalize(data.weather.description))
.setAuthor({
name: `${city} ยท ${main}`,
iconURL: `${moon[Moon.lunarPhase()]}` as string,
})
4 replies
DIAdiscord.js - Imagine an app
Created by Mara on 7/10/2023 in #djs-questions
get "Global display name"
Hello! Since the discord update, discriminator disappear, and we have now the option to set a "global display name". For example, mine is "Mara", and my pomelo is "mara__li". I want to know how I can get the global display name with the discordJS api. I tried: - user.username - member.nickname - member.displayName I'm in DJS v14.11.0
4 replies
DIAdiscord.js - Imagine an app
Created by Mara on 7/9/2023 in #djs-questions
Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at <time>
Hello! My bot Knitting is host on a VPS (oracle free tier). I have two bot on this VPS, and the second work as excepted. Knitting won't run, and I have this error : Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at. The bot don't use sharding, because it's not on many guild. Here the full stack:
0|knitting | 2023-07-09 09:42 +00:00: Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-07-09T17:35:25.997Z
0|knitting | 2023-07-09 09:42 +00:00: at WebSocketManager.connect (/home/ubuntu/DiscordThreadMember/node_modules/.pnpm/@discordjs+ws@0.8.3/node_modules/@discordjs/ws/dist/index.js:1363:13)
0|knitting | 2023-07-09 09:42 +00:00: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|knitting | 2023-07-09 09:42 +00:00: at async WebSocketManager.connect (/home/ubuntu/DiscordThreadMember/node_modules/.pnpm/discord.js@14.11.0/node_modules/discord.js/src/client/websocket/WebSocketManager.js:206:5)
0|knitting | 2023-07-09 09:42 +00:00: at async Client.login (/home/ubuntu/DiscordThreadMember/node_modules/.pnpm/discord.js@14.11.0/node_modules/discord.js/src/client/Client.js:226:7)
0|knitting | 2023-07-09 09:42 +00:00: Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-07-09T17:35:25.997Z
0|knitting | 2023-07-09 09:42 +00:00: at WebSocketManager.connect (/home/ubuntu/DiscordThreadMember/node_modules/.pnpm/@discordjs+ws@0.8.3/node_modules/@discordjs/ws/dist/index.js:1363:13)
0|knitting | 2023-07-09 09:42 +00:00: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|knitting | 2023-07-09 09:42 +00:00: at async WebSocketManager.connect (/home/ubuntu/DiscordThreadMember/node_modules/.pnpm/discord.js@14.11.0/node_modules/discord.js/src/client/websocket/WebSocketManager.js:206:5)
0|knitting | 2023-07-09 09:42 +00:00: at async Client.login (/home/ubuntu/DiscordThreadMember/node_modules/.pnpm/discord.js@14.11.0/node_modules/discord.js/src/client/Client.js:226:7)
6 replies