🎨 formatted files
This commit is contained in:
parent
8a48c44a80
commit
8f081f3863
20 changed files with 433 additions and 339 deletions
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"printWidth": 100,
|
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true
|
"singleQuote": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,6 @@
|
||||||
"clientId": "required",
|
"clientId": "required",
|
||||||
"guildId": "required"
|
"guildId": "required"
|
||||||
},
|
},
|
||||||
"credits": {
|
|
||||||
"url": "scheme://domain/api/",
|
|
||||||
"token": "required",
|
|
||||||
"timeout": "5000",
|
|
||||||
"rate": "1",
|
|
||||||
"minimumLength": "5",
|
|
||||||
"excludedChannels": [
|
|
||||||
"channel_id",
|
|
||||||
"channel_id"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"colors": {
|
"colors": {
|
||||||
"success": "0x22bb33",
|
"success": "0x22bb33",
|
||||||
"error": "0xbb2124",
|
"error": "0xbb2124",
|
||||||
|
|
0
log.json
0
log.json
|
@ -45,14 +45,18 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
// Get toUser object
|
// Get toUser object
|
||||||
|
|
||||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
const toUser = await credits.findOne({
|
||||||
|
userId: user.id,
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
// Stop if user has zero or below credits
|
// Stop if user has zero or below credits
|
||||||
|
|
||||||
if (!toUser) {
|
if (!toUser) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Give',
|
title: 'Give',
|
||||||
description: 'That user has no credits, I can not give credits to the user',
|
description:
|
||||||
|
'That user has no credits, I can not give credits to the user',
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -86,7 +90,9 @@ module.exports = async (interaction) => {
|
||||||
// Send debug message
|
// Send debug message
|
||||||
|
|
||||||
await logger.debug(
|
await logger.debug(
|
||||||
`Guild: ${member.guild.id} User: ${member.id} gave ${user.id} ${creditNoun(amount)}.`
|
`Guild: ${member.guild.id} User: ${member.id} gave ${
|
||||||
|
user.id
|
||||||
|
} ${creditNoun(amount)}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,14 +45,18 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
// Get toUser object
|
// Get toUser object
|
||||||
|
|
||||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
const toUser = await credits.findOne({
|
||||||
|
userId: user.id,
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
// Stop if user has zero or below credits
|
// Stop if user has zero or below credits
|
||||||
|
|
||||||
if (!toUser) {
|
if (!toUser) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Set',
|
title: 'Set',
|
||||||
description: 'That user has no credits, I can not set credits to the user',
|
description:
|
||||||
|
'That user has no credits, I can not set credits to the user',
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -86,7 +90,9 @@ module.exports = async (interaction) => {
|
||||||
// Send debug message
|
// Send debug message
|
||||||
|
|
||||||
await logger.debug(
|
await logger.debug(
|
||||||
`Guild: ${member.guild.id} User: ${member.id} set ${user.id} to ${creditNoun(amount)}.`
|
`Guild: ${member.guild.id} User: ${member.id} set ${
|
||||||
|
user.id
|
||||||
|
} to ${creditNoun(amount)}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,14 +45,18 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
// Get toUser object
|
// Get toUser object
|
||||||
|
|
||||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
const toUser = await credits.findOne({
|
||||||
|
userId: user.id,
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
// Stop if user has zero or below credits
|
// Stop if user has zero or below credits
|
||||||
|
|
||||||
if (!toUser) {
|
if (!toUser) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Take',
|
title: 'Take',
|
||||||
description: 'That user has no credits, I can not take credits from the user',
|
description:
|
||||||
|
'That user has no credits, I can not take credits from the user',
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -86,7 +90,9 @@ module.exports = async (interaction) => {
|
||||||
// Send debug message
|
// Send debug message
|
||||||
|
|
||||||
await logger.debug(
|
await logger.debug(
|
||||||
`Guild: ${member.guild.id} User: ${member.id} took ${creditNoun(amount)} from ${user.id}.`
|
`Guild: ${member.guild.id} User: ${member.id} took ${creditNoun(
|
||||||
|
amount
|
||||||
|
)} from ${user.id}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,18 +34,25 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
// Get fromUser object
|
// Get fromUser object
|
||||||
|
|
||||||
const fromUser = await credits.findOne({ userId: from.id, guildId: interaction.member.guild.id });
|
const fromUser = await credits.findOne({
|
||||||
|
userId: from.id,
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
// Get toUser object
|
// Get toUser object
|
||||||
|
|
||||||
const toUser = await credits.findOne({ userId: to.id, guildId: interaction.member.guild.id });
|
const toUser = await credits.findOne({
|
||||||
|
userId: to.id,
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
// Stop if fromUser has zero credits or below
|
// Stop if fromUser has zero credits or below
|
||||||
|
|
||||||
if (!fromUser) {
|
if (!fromUser) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Transfer',
|
title: 'Transfer',
|
||||||
description: 'That user has no credits, I can not transfer credits from the user',
|
description:
|
||||||
|
'That user has no credits, I can not transfer credits from the user',
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -58,7 +65,8 @@ module.exports = async (interaction) => {
|
||||||
if (!toUser) {
|
if (!toUser) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Transfer',
|
title: 'Transfer',
|
||||||
description: 'That user has no credits, I can not transfer credits to the user',
|
description:
|
||||||
|
'That user has no credits, I can not transfer credits to the user',
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -115,9 +123,9 @@ module.exports = async (interaction) => {
|
||||||
// Send debug message
|
// Send debug message
|
||||||
|
|
||||||
await logger.debug(
|
await logger.debug(
|
||||||
`Guild: ${member.guild.id} User: ${member.id} transferred ${creditNoun(amount)} from ${
|
`Guild: ${member.guild.id} User: ${member.id} transferred ${creditNoun(
|
||||||
from.id
|
amount
|
||||||
} to ${to.id}.`
|
)} from ${from.id} to ${to.id}.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,10 +16,16 @@ module.exports = {
|
||||||
.setName('give')
|
.setName('give')
|
||||||
.setDescription('Give credits to a user')
|
.setDescription('Give credits to a user')
|
||||||
.addUserOption((option) =>
|
.addUserOption((option) =>
|
||||||
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
|
option
|
||||||
|
.setName('user')
|
||||||
|
.setDescription('The user you want to pay.')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
|
option
|
||||||
|
.setName('amount')
|
||||||
|
.setDescription('The amount you will pay.')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSubcommand((command) =>
|
.addSubcommand((command) =>
|
||||||
|
@ -33,7 +39,10 @@ module.exports = {
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option.setName('amount').setDescription('The amount you will set.').setRequired(true)
|
option
|
||||||
|
.setName('amount')
|
||||||
|
.setDescription('The amount you will set.')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSubcommand((command) =>
|
.addSubcommand((command) =>
|
||||||
|
@ -47,7 +56,10 @@ module.exports = {
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option.setName('amount').setDescription('The amount you will take.').setRequired(true)
|
option
|
||||||
|
.setName('amount')
|
||||||
|
.setDescription('The amount you will take.')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSubcommand((command) =>
|
.addSubcommand((command) =>
|
||||||
|
|
|
@ -30,7 +30,9 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Balance',
|
title: 'Balance',
|
||||||
description: `${user ? `${user} has` : 'You have'} ${creditNoun(balance)}.`,
|
description: `${user ? `${user} has` : 'You have'} ${creditNoun(
|
||||||
|
balance
|
||||||
|
)}.`,
|
||||||
color: config.colors.success,
|
color: config.colors.success,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
|
|
@ -52,12 +52,16 @@ module.exports = async (interaction) => {
|
||||||
userId: interaction.user.id,
|
userId: interaction.user.id,
|
||||||
guildId: interaction.member.guild.id,
|
guildId: interaction.member.guild.id,
|
||||||
});
|
});
|
||||||
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
|
const toUser = await credits.findOne({
|
||||||
|
userId: user.id,
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
if (!toUser) {
|
if (!toUser) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Gift',
|
title: 'Gift',
|
||||||
description: 'That user has no credits, I can not gift credits to the user',
|
description:
|
||||||
|
'That user has no credits, I can not gift credits to the user',
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -80,7 +84,9 @@ module.exports = async (interaction) => {
|
||||||
};
|
};
|
||||||
const dmEmbed = {
|
const dmEmbed = {
|
||||||
title: 'Gift',
|
title: 'Gift',
|
||||||
description: `You received ${creditNoun(amount)} from ${interaction.user}${
|
description: `You received ${creditNoun(amount)} from ${
|
||||||
|
interaction.user
|
||||||
|
}${
|
||||||
reason ? ` with reason: ${reason}` : ''
|
reason ? ` with reason: ${reason}` : ''
|
||||||
}. Your new balance is ${creditNoun(toUser.balance)}.`,
|
}. Your new balance is ${creditNoun(toUser.balance)}.`,
|
||||||
color: 0x22bb33,
|
color: 0x22bb33,
|
||||||
|
@ -89,8 +95,13 @@ module.exports = async (interaction) => {
|
||||||
};
|
};
|
||||||
const dmUser = await interaction.client.users.cache.get(user.id);
|
const dmUser = await interaction.client.users.cache.get(user.id);
|
||||||
await dmUser.send({ embeds: [dmEmbed] });
|
await dmUser.send({ embeds: [dmEmbed] });
|
||||||
await logger.debug(`Gift sent from: ${interaction.user.username} to: ${user.username}`);
|
await logger.debug(
|
||||||
return await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
|
`Gift sent from: ${interaction.user.username} to: ${user.username}`
|
||||||
|
);
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [interactionEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await logger.error(e);
|
await logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@ module.exports = async (interaction) => {
|
||||||
userId: interaction.user.id,
|
userId: interaction.user.id,
|
||||||
guildId: interaction.member.guild.id,
|
guildId: interaction.member.guild.id,
|
||||||
});
|
});
|
||||||
const dmUser = interaction.client.users.cache.get(interaction.member.user.id);
|
const dmUser = interaction.client.users.cache.get(
|
||||||
|
interaction.member.user.id
|
||||||
|
);
|
||||||
|
|
||||||
if ((amount || user.balance) < 100) {
|
if ((amount || user.balance) < 100) {
|
||||||
const embed = {
|
const embed = {
|
||||||
|
@ -61,7 +63,9 @@ module.exports = async (interaction) => {
|
||||||
}
|
}
|
||||||
const code = uuidv4();
|
const code = uuidv4();
|
||||||
|
|
||||||
const apiCredentials = await apis.findOne({ guildId: interaction.member.guild.id });
|
const apiCredentials = await apis.findOne({
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: apiCredentials.url,
|
baseURL: apiCredentials.url,
|
||||||
|
@ -78,7 +82,9 @@ module.exports = async (interaction) => {
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const dmEmbed = {
|
const dmEmbed = {
|
||||||
title: 'Redeem',
|
title: 'Redeem',
|
||||||
description: `Your new balance is ${user.balance - (amount || user.balance)}.`,
|
description: `Your new balance is ${
|
||||||
|
user.balance - (amount || user.balance)
|
||||||
|
}.`,
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'Code', value: `${code}`, inline: true },
|
{ name: 'Code', value: `${code}`, inline: true },
|
||||||
{
|
{
|
||||||
|
@ -102,9 +108,14 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
await user.save();
|
await user.save();
|
||||||
|
|
||||||
await logger.debug(`User: ${user.username} redeemed: ${creditNoun(amount)}`);
|
await logger.debug(
|
||||||
|
`User: ${user.username} redeemed: ${creditNoun(amount)}`
|
||||||
|
);
|
||||||
await dmUser.send({ embeds: [dmEmbed] });
|
await dmUser.send({ embeds: [dmEmbed] });
|
||||||
await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
|
await interaction.editReply({
|
||||||
|
embeds: [interactionEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
await logger.error(e);
|
await logger.error(e);
|
||||||
|
|
|
@ -3,18 +3,25 @@ const credits = require('../../../helpers/database/models/creditSchema');
|
||||||
const creditNoun = require('../../../helpers/creditNoun');
|
const creditNoun = require('../../../helpers/creditNoun');
|
||||||
|
|
||||||
module.exports = async (interaction) => {
|
module.exports = async (interaction) => {
|
||||||
await credits.find({ guildId: interaction.member.guild.id }).then(async (data) => {
|
await credits
|
||||||
const topTen = data.sort((a, b) => (a.balance > b.balance ? -1 : 1)).slice(0, 10);
|
.find({ guildId: interaction.member.guild.id })
|
||||||
|
.then(async (data) => {
|
||||||
|
const topTen = data
|
||||||
|
.sort((a, b) => (a.balance > b.balance ? -1 : 1))
|
||||||
|
.slice(0, 10);
|
||||||
|
|
||||||
const item = (x, index) => `**Top ${index + 1}** - <@${x.userId}> ${creditNoun(x.balance)}`;
|
const item = (x, index) =>
|
||||||
|
`**Top ${index + 1}** - <@${x.userId}> ${creditNoun(x.balance)}`;
|
||||||
|
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Balance Top',
|
title: 'Balance Top',
|
||||||
description: `Below are the top ten.\n${topTen.map((x, index) => item(x, index)).join('\n')}`,
|
description: `Below are the top ten.\n${topTen
|
||||||
color: 0x22bb33,
|
.map((x, index) => item(x, index))
|
||||||
timestamp: new Date(),
|
.join('\n')}`,
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
color: 0x22bb33,
|
||||||
};
|
timestamp: new Date(),
|
||||||
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
});
|
};
|
||||||
|
return interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
const config = require('../../../../config.json');
|
const config = require('../../../../config.json');
|
||||||
const logger = require('../../../handlers/logger');
|
const logger = require('../../../handlers/logger');
|
||||||
const { guilds, credits, timeouts } = require('../../../helpers/database/models');
|
const {
|
||||||
|
guilds,
|
||||||
|
credits,
|
||||||
|
timeouts,
|
||||||
|
} = require('../../../helpers/database/models');
|
||||||
const creditNoun = require('../../../helpers/creditNoun');
|
const creditNoun = require('../../../helpers/creditNoun');
|
||||||
|
|
||||||
const workedRecently = new Set();
|
const workedRecently = new Set();
|
||||||
|
@ -20,7 +24,9 @@ module.exports = async (interaction) => {
|
||||||
// If user is not on timeout
|
// If user is not on timeout
|
||||||
|
|
||||||
if (!isTimeout) {
|
if (!isTimeout) {
|
||||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
const guild = await guilds.findOne({
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
const creditsEarned = Math.floor(Math.random() * guild.credits.workRate);
|
const creditsEarned = Math.floor(Math.random() * guild.credits.workRate);
|
||||||
await credits
|
await credits
|
||||||
|
@ -55,7 +61,9 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await logger.debug(
|
await logger.debug(
|
||||||
`Guild: ${member.guild.id} User: ${member.id} has not worked within the last ${
|
`Guild: ${member.guild.id} User: ${
|
||||||
|
member.id
|
||||||
|
} has not worked within the last ${
|
||||||
guild.work.timeout / 1000
|
guild.work.timeout / 1000
|
||||||
} seconds, work can be done`
|
} seconds, work can be done`
|
||||||
);
|
);
|
||||||
|
|
|
@ -30,7 +30,9 @@ module.exports = {
|
||||||
.setName('redeem')
|
.setName('redeem')
|
||||||
.setDescription('Redeem your credits.')
|
.setDescription('Redeem your credits.')
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option.setName('amount').setDescription('How much credit you want to withdraw.')
|
option
|
||||||
|
.setName('amount')
|
||||||
|
.setDescription('How much credit you want to withdraw.')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
|
@ -38,21 +40,36 @@ module.exports = {
|
||||||
.setName('gift')
|
.setName('gift')
|
||||||
.setDescription('Gift someone credits from your credits.')
|
.setDescription('Gift someone credits from your credits.')
|
||||||
.addUserOption((option) =>
|
.addUserOption((option) =>
|
||||||
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
|
option
|
||||||
|
.setName('user')
|
||||||
|
.setDescription('The user you want to pay.')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
|
option
|
||||||
|
.setName('amount')
|
||||||
|
.setDescription('The amount you will pay.')
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option.setName('reason').setDescription('Your reason.')
|
||||||
)
|
)
|
||||||
.addStringOption((option) => option.setName('reason').setDescription('Your reason.'))
|
|
||||||
)
|
)
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
subcommand.setName('top').setDescription('Check the top balance.')
|
subcommand.setName('top').setDescription('Check the top balance.')
|
||||||
)
|
)
|
||||||
.addSubcommand((subcommand) => subcommand.setName('work').setDescription('Work for credits.')),
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand.setName('work').setDescription('Work for credits.')
|
||||||
|
),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
|
const guild = await guilds.findOne({
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
if (guild.credits.status === false && interaction.options.getSubcommand() !== 'settings') {
|
if (
|
||||||
|
guild.credits.status === false &&
|
||||||
|
interaction.options.getSubcommand() !== 'settings'
|
||||||
|
) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Credits',
|
title: 'Credits',
|
||||||
description: 'Please enable credits by ``/credits settings``',
|
description: 'Please enable credits by ``/credits settings``',
|
||||||
|
|
27
src/helpers/database/models/profileSchema.js
Normal file
27
src/helpers/database/models/profileSchema.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
|
||||||
|
const profileSchema = new mongoose.Schema(
|
||||||
|
{
|
||||||
|
userId: {
|
||||||
|
type: mongoose.SchemaTypes.Decimal128,
|
||||||
|
required: true,
|
||||||
|
unique: false,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
required: true,
|
||||||
|
unique: false,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
token: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
required: true,
|
||||||
|
unique: false,
|
||||||
|
index: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
module.exports = mongoose.model('profile', profileSchema);
|
33
src/index.js
33
src/index.js
|
@ -1,16 +1,19 @@
|
||||||
/* eslint-disable no-restricted-syntax */
|
const fs = require('fs');
|
||||||
|
const { Client, Collection, Intents } = require('discord.js');
|
||||||
|
|
||||||
require('./deploy-commands')();
|
require('./deploy-commands')();
|
||||||
require('./helpers/database')();
|
require('./helpers/database')();
|
||||||
require('./handlers/locale')();
|
require('./handlers/locale')();
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const { Client, Collection, Intents } = require('discord.js');
|
|
||||||
|
|
||||||
const config = require('../config.json');
|
const config = require('../config.json');
|
||||||
|
|
||||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
|
const client = new Client({
|
||||||
|
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
|
||||||
|
});
|
||||||
|
|
||||||
const eventFiles = fs.readdirSync('./src/events').filter((file) => file.endsWith('.js'));
|
const eventFiles = fs
|
||||||
|
.readdirSync('./src/events')
|
||||||
|
.filter((file) => file.endsWith('.js'));
|
||||||
|
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
const commandFiles = fs.readdirSync('./src/commands');
|
const commandFiles = fs.readdirSync('./src/commands');
|
||||||
|
@ -21,24 +24,6 @@ for (const file of commandFiles) {
|
||||||
client.commands.set(command.data.name, command);
|
client.commands.set(command.data.name, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
// client.buttons = new Collection();
|
|
||||||
// const buttonFiles = fs.readdirSync('./src/buttons');
|
|
||||||
|
|
||||||
// for (const file of buttonFiles) {
|
|
||||||
// // eslint-disable-next-line import/no-dynamic-require, global-require
|
|
||||||
// const button = require(`./buttons/${file}`);
|
|
||||||
// client.buttons.set(button.customId, button);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// client.menus = new Collection();
|
|
||||||
// const menuFiles = fs.readdirSync('./src/menus');
|
|
||||||
|
|
||||||
// for (const file of menuFiles) {
|
|
||||||
// // eslint-disable-next-line import/no-dynamic-require, global-require
|
|
||||||
// const menu = require(`./menus/${file}`);
|
|
||||||
// client.menus.set(menu.customId, menu);
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (const file of eventFiles) {
|
for (const file of eventFiles) {
|
||||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||||
const event = require(`./events/${file}`);
|
const event = require(`./events/${file}`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue