ShiNxz
ShiNxz
DIAdiscord.js - Imagine an app
Created by ShiNxz on 7/19/2024 in #djs-voice
Error when joining a voice
No description
3 replies
DIAdiscord.js - Imagine an app
Created by ShiNxz on 7/29/2023 in #djs-questions
Context Menu
Hey, I'm trying to register context menu commands but not sure how. I've a command handler that sending a put request to discord with a set of comamnds, and it does work well, but im not sure how to do that with the context menus.. example of a menu event file:
import type { ContextMenu } from '@/types/discord'
import { ApplicationCommandType, ContextMenuCommandBuilder } from 'discord.js'

const ClearCommand: ContextMenu = {
command: new ContextMenuCommandBuilder().setName('Profile').setType(ApplicationCommandType.User),

execute: (interaction) => {
console.log(interaction)
},

description: 'Gets the user profile in the website',
cooldown: 5,
staff: false,
}

export default ClearCommand
import type { ContextMenu } from '@/types/discord'
import { ApplicationCommandType, ContextMenuCommandBuilder } from 'discord.js'

const ClearCommand: ContextMenu = {
command: new ContextMenuCommandBuilder().setName('Profile').setType(ApplicationCommandType.User),

execute: (interaction) => {
console.log(interaction)
},

description: 'Gets the user profile in the website',
cooldown: 5,
staff: false,
}

export default ClearCommand
And this is my menu handler, which doesnt work. sometimes it does work for 2 seconds and then doesnt for a few minutes, but im not even think it should work like that..
...
const dir = readdirp(menusDir, { fileFilter: ['*.ts', '*.js'] })

for await (const file of dir) {
let contextMenu: ContextMenu = (await import(`${pathToFileURL(file.fullPath)}`)).default
contextMenus.push(contextMenu.command)
client.contextMenus.set(contextMenu.command.name, contextMenu)
}

const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN!)

const isDev = process.env.MODE === 'dev'

const route = isDev
? Routes.applicationGuildCommands(process.env.BOT_CLIENT_ID!, process.env.GUILD_ID!)
: Routes.applicationCommands(process.env.BOT_CLIENT_ID!)

// Should I do that?
const data: any = await rest.put(route, {
body: contextMenus,
headers: { 'Content-Type': 'application/json' },
})
...
...
const dir = readdirp(menusDir, { fileFilter: ['*.ts', '*.js'] })

for await (const file of dir) {
let contextMenu: ContextMenu = (await import(`${pathToFileURL(file.fullPath)}`)).default
contextMenus.push(contextMenu.command)
client.contextMenus.set(contextMenu.command.name, contextMenu)
}

const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN!)

const isDev = process.env.MODE === 'dev'

const route = isDev
? Routes.applicationGuildCommands(process.env.BOT_CLIENT_ID!, process.env.GUILD_ID!)
: Routes.applicationCommands(process.env.BOT_CLIENT_ID!)

// Should I do that?
const data: any = await rest.put(route, {
body: contextMenus,
headers: { 'Content-Type': 'application/json' },
})
...
Thanks!
19 replies
DIAdiscord.js - Imagine an app
Created by ShiNxz on 7/26/2023 in #djs-questions
Typescript template/support
Hey, I want to convert my discord.js javascript bot to typescript, is there any good or popular discord.js template/tutorial for the deploying and stuff? Need something that supports event, interactions, etc, handlers.
5 replies
DIAdiscord.js - Imagine an app
Created by ShiNxz on 12/26/2022 in #djs-questions
Hey, is discordjs is working with typescript? or do i need to compile the application first?
Hey, is discordjs is working with typescript? or do i need to compile the application first?
8 replies
DIAdiscord.js - Imagine an app
Created by ShiNxz on 10/26/2022 in #djs-questions
Open locked or archived post
Hey, is it possible to open a locked or archived post in djs?
6 replies