i want to let a bot use slash commands of another bot. If i send a message like /help it will not use the Slash function, instead it will just send "/help" (is not using the Slash Command function). Does anyone know if this is even possible?
i want to let a bot use slash commands of another bot. If i send a message like /help it will not use the Slash function, instead it will just send "/help" (is not using the Slash Command function). Does anyone know if this is even possible?
Assuming my comment is what you were looking for this should solve your query.
// Bot 1
const {
Client
} = require("discord.js")
const client = new Client({
intents: '...'
})
const prefix = '/'
client.on('messageCreate', async message => {
if (message.content.startsWith(prefix) && !message.author.bot) {
const command = `/${message.content}`
const response = message.reply(`${message.author}, relaying command`)
await response.then(message.channel.send(command))
}
})
// Bot 2
const {
Client
} = require("discord.js")
const client = new Client({
intents: '...'
})
const bot_1_id = '4654564984981981894654'
const prefix = '/'
client.on('messageCreate', async message => {
if (message.author.bot && message.author.id === bot_1_id && message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/)
const cmd = args.shift().toLowerCase()
const command = client.commands.get(cmd)
// if you don't have command files
if (cmd === 'help') {
message.channel.send(`${message.author} I recognized your help command`)
return
}
// if you have a command files see below script for file
if (!command) return
try {
command.execute(message, args)
} catch (error) {
console.error(error)
message.reply(`Couldn't run command`)
}
} else {
return
}
})
Optional if you want to/do use command files
// Command File
module.exports = {
name: 'help',
description: 'help command',
async execute(message, args) {
message.channel.send(`${message.author} I recognized your help command`)
return
}
}