pandoapi
Version:
API interna para los bots de PandoTeam
27 lines (17 loc) • 1.27 kB
JavaScript
async function reply(client, channelID, messageID, message) {
if(!client || !channelID || !messageID || !message) return ('Api-Error on(Parameters) : No ha proporcionado los parametros necesarios.');
if(!client.user) return ('Api-Error on(getClientUser) : No se pudo obtener el usuario del cliente.');
if(!client.user.id) return ('Api-Error on(getClientUserID) : No se pudo obtener la ID del cliente.');
const authorization = require('../authorized.js');
const authorize = await authorization.authorize(client);
if(authorize === false) return ('Api-Error on(Authorization) : El cliente no está autorizado para usar este servicio.');
if(typeof message !== 'string') return ('Api-Error on(validMessage) : El mensaje tiene que ser de tipo string.');
let channel = client.channels.cache.get(channelID);
if(!channel) return ('Api-Error on(getChannel) : No se pudo encontrar el canal introducido.');
channel.messages.fetch(messageID).catch((err) => {
return (`Api-Error on(package(discord.js)) : ${err}`);
})
await client.api.channels[channelID].messages.post({ data: { content: message, message_reference: { message_id: messageID } } });
return true;
}
module.exports = reply;