discordjs-giveaways
Version:
A customisable giveaways manager for Discord.js v14 and mysql
126 lines (123 loc) • 5.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.notInServer = exports.participationRegistered = exports.noEntries = exports.winners = exports.removeParticipation = exports.notParticipated = exports.alreadyParticipate = exports.entryAllowed = exports.missingRequiredRoles = exports.hasDeniedRoles = exports.ended = exports.giveaway = void 0;
const discord_js_1 = require("discord.js");
const giveaway = (data) => {
const embed = new discord_js_1.EmbedBuilder().setTitle('🎉 Giveaway 🎉').setColor('#00ff00').setDescription(`**${data.reward}**
Hosted by <@${data.hoster_id}>
**${data.winnerCount}** winner${data.winnerCount > 1 ? 's' : ''}
Entries : ${data.participants?.length ?? '0'}
Ends <t:${((data.time + Date.now()) / 1000).toFixed(0)}:R>`);
if (data.bonus_roles && data.bonus_roles.length > 0) {
embed.addFields({
name: 'Bonus roles',
value: data.bonus_roles.map((rId) => `<@&${rId}>`).join(' '),
inline: false
});
}
if (data.required_roles && data.required_roles.length > 0) {
embed.addFields({
name: 'Required roles',
value: data.required_roles.map((rId) => `<@&${rId}>`).join(' '),
inline: false
});
}
if (data.denied_roles && data.denied_roles.length > 0) {
embed.addFields({
name: 'Denied roles',
value: data.denied_roles.map((rId) => `<@&${rId}>`).join(' '),
inline: false
});
}
if (data.required_servers && data.required_servers.length > 0) {
embed.addFields({
name: 'Required servers',
value: data.required_servers
.map((s) => `[${s.name}](${s.invitation})`)
.join('\n'),
inline: false
});
}
return embed;
};
exports.giveaway = giveaway;
const ended = (data, winners) => {
const embed = new discord_js_1.EmbedBuilder().setTitle('🎉 Giveaway ended 🎉').setColor('#ff0000').setDescription(`**${data.reward}**
Hosted by <@${data.hoster_id}>
${winners.length > 0
? `Winner${data.winnerCount > 1 ? 's' : ''} : ${winners.map((x) => `<@${x}>`).join(' ')}`
: 'No winner'}
Entries: ${data.participants.length}
Ended <t:${(Date.now() / 1000).toFixed(0)}:R>`);
return embed;
};
exports.ended = ended;
const hasDeniedRoles = (deniedRoles, url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🚫 Access denied')
.setDescription(`The access to [**this giveaway**](${url}) is denied for **you** because you have one of theses roles :\n${deniedRoles
.map((x) => `<@&${x}>`)
.join(' ')}`)
.setColor('#ff0000');
};
exports.hasDeniedRoles = hasDeniedRoles;
const missingRequiredRoles = (requiredRoles, url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🚫 Access denied')
.setDescription(`The access to [**this giveaway**](${url}) is denied for **you** because you don't have all theses roles :\n${requiredRoles
.map((x) => `<@&${x}>`)
.join(' ')}`)
.setColor('#ff0000');
};
exports.missingRequiredRoles = missingRequiredRoles;
const entryAllowed = (url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🎉 Entry Allowed')
.setColor('#00ff00')
.setDescription(`The entry to [**this giveaway**](${url}) is allowed.\nGood luck !`);
};
exports.entryAllowed = entryAllowed;
const alreadyParticipate = (url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🚫 Already participated')
.setDescription(`You already participate to [**this giveaway**](${url}).`)
.setColor('#ff0000');
};
exports.alreadyParticipate = alreadyParticipate;
const notParticipated = (url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🚫 Not participed')
.setDescription(`You have not participated to [**this giveaway**](${url})`)
.setColor('#ff0000');
};
exports.notParticipated = notParticipated;
const removeParticipation = (url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('❌ Entry removed')
.setDescription(`I removed your entry to [**this giveaway**](${url}).`)
.setColor('#00ff00');
};
exports.removeParticipation = removeParticipation;
const winners = (winners, data, url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🎉 Winners')
.setDescription(`The winner${winners.length > 1 ? 's' : ''} of [**this giveaway**](${url}) ${winners.length > 1 ? 'are' : 'is'} ${winners.map((x) => `<@${x}>`).join(' ')}`)
.setColor('#00ff00');
};
exports.winners = winners;
const noEntries = (url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('No winner')
.setDescription(`No winner can be found for [**this giveaway**](${url})`)
.setColor('#ff0000');
};
exports.noEntries = noEntries;
const participationRegistered = (url) => {
return new discord_js_1.EmbedBuilder()
.setTitle('🎉 Participation registered')
.setDescription(`I registered your participation to [**this giveaway**](${url})`)
.setColor('#00FF00');
};
exports.participationRegistered = participationRegistered;
const notInServer = (url, servers) => new discord_js_1.EmbedBuilder().setTitle('🚫 Access denied').setDescription(`The access to [**this giveaway**](${url}) is denied for **you** because you are not in one of these servers :\n${servers.map(x => `[${x.name}](${x.link})`)}`).setColor('#ff0000');
exports.notInServer = notInServer;