djs-systems
Version:
The simplest way to build complex Discord bots.
71 lines (70 loc) • 2.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.nqn = void 0;
const error_1 = require("../error");
// ------------------------------
// ------ F U N C T I O N -------
// ------------------------------
/**
* @deprecated Removed from the package
*
* NQN bot feature. But you have the power to do it.
* @param message
* @link `Documentation:` https://simplyd.js.org/docs/deprecated/nqn
* @example simplydjs.nqn(message)
*/
async function nqn(message, options = { strict: false }) {
(0, error_1.Deprecated)({
desc: 'Removed nqn() from the package. Please use other package or our code in github.'
});
return new Promise(async () => {
try {
const { client } = message;
if (message.author.bot)
return;
const msg = message.content;
if (msg.includes('<:') || msg.includes('<a:'))
return;
const str = msg.match(/(:)([^:\s]+)(:)/gi);
let reply = message.content;
if (str && str[0]) {
str.forEach(async (emo) => {
const rlem = emo.replaceAll(':', '');
const emoji = message.guild.emojis.cache.find((x) => x.name === rlem) ||
client.emojis.cache.find((x) => x.name === rlem);
if (!emoji?.id)
return;
reply = reply.replace(emo, emoji?.toString());
});
let webhook = await (await message.channel.fetchWebhooks()).find((w) => w.name == `simply-djs NQN`);
if (!webhook) {
webhook = await message.channel.createWebhook({
name: `simply-djs NQN`,
avatar: client.user.displayAvatarURL({
forceStatic: false
})
});
}
await message.delete();
await webhook.send({
username: message.member.nickname || message.author.username,
avatarURL: message.author.displayAvatarURL({
forceStatic: false
}),
content: reply
});
}
}
catch (err) {
if (options?.strict)
throw new error_1.SimplyError({
function: 'nqn',
title: 'An Error occured when running the function ',
tip: err.stack
});
else
console.log(`SimplyError - nqn | Error: ${err.stack}`);
}
});
}
exports.nqn = nqn;