Restyled by prettier

This commit is contained in:
Restyled.io 2022-03-06 18:41:29 +00:00 committed by Axel Olausson Holtenäs
parent 820ee57844
commit 18b559a867
No known key found for this signature in database
GPG key ID: E3AE7E194AE017ED
10 changed files with 476 additions and 524 deletions

View file

@ -12,7 +12,7 @@ module.exports = async (interaction) => {
// eslint-disable-next-line max-len
.findOne({
userId: user ? user.id : interaction.user.id,
guildId : interaction.member.guild.id
guildId: interaction.member.guild.id,
})
.then(async (data) => {
if (!data) {
@ -21,19 +21,16 @@ module.exports = async (interaction) => {
description: `${user} has no credits.`,
color: config.colors.success,
timestamp: new Date(),
footer :
{iconURL : config.footer.icon, text : config.footer.text},
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return interaction.editReply({ embeds: [embed], ephemeral: true });
}
const { balance } = data;
const embed = {
title: 'Balance',
description :
`${user ? `${user} has` : 'You have'} ${creditNoun(balance)}.`,
description: `${user ? `${user} has` : 'You have'} ${creditNoun(balance)}.`,
color: config.colors.success,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },

View file

@ -11,8 +11,10 @@ module.exports = async (interaction) => {
const amount = await interaction.options.getInteger('amount');
const reason = await interaction.options.getString('reason');
// eslint-disable-next-line max-len
const data = await credits.findOne(
{userId : interaction.user.id, guildId : interaction.member.guild.id});
const data = await credits.findOne({
userId: interaction.user.id,
guildId: interaction.member.guild.id,
});
if (user.id === interaction.user.id) {
const embed = {
@ -22,8 +24,7 @@ module.exports = async (interaction) => {
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
if (amount <= 0) {
const embed = {
@ -33,32 +34,29 @@ module.exports = async (interaction) => {
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
if (data.balance < amount) {
const embed = {
title: 'Gift',
description :
`You have insufficient credits. Your balance is ${data.balance}`,
description: `You have insufficient credits. Your balance is ${data.balance}`,
color: 0xbb2124,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
// eslint-disable-next-line max-len
const fromUser = await credits.findOne(
{userId : interaction.user.id, guildId : interaction.member.guild.id});
const toUser = await credits.findOne(
{userId : user.id, guildId : interaction.member.guild.id});
const fromUser = await credits.findOne({
userId: interaction.user.id,
guildId: interaction.member.guild.id,
});
const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id });
if (!toUser) {
const embed = {
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,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
@ -73,32 +71,25 @@ module.exports = async (interaction) => {
const interactionEmbed = {
title: 'Gift',
description: `You sent ${creditNoun(amount)} to ${user}${
reason ? ` with reason: ${reason}` : ''}. Your new balance is ${
creditNoun(
fromUser.balance,
)}.`,
reason ? ` with reason: ${reason}` : ''
}. Your new balance is ${creditNoun(fromUser.balance)}.`,
color: 0x22bb33,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
const dmEmbed = {
title: 'Gift',
description :
`You received ${creditNoun(amount)} from ${interaction.user}${
reason ? ` with reason: ${reason}` : ''}. Your new balance is ${
creditNoun(
toUser.balance,
)}.`,
description: `You received ${creditNoun(amount)} from ${interaction.user}${
reason ? ` with reason: ${reason}` : ''
}. Your new balance is ${creditNoun(toUser.balance)}.`,
color: 0x22bb33,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
const dmUser = await interaction.client.users.cache.get(user.id);
await dmUser.send({ embeds: [dmEmbed] });
await logger.debug(
`Gift sent from: ${interaction.user.username} to: ${user.username}`);
return await interaction.editReply(
{embeds : [ interactionEmbed ], ephemeral : true});
await logger.debug(`Gift sent from: ${interaction.user.username} to: ${user.username}`);
return await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
} catch (e) {
await logger.error(e);
}

View file

@ -11,11 +11,9 @@ module.exports = async (interaction) => {
if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
const embed = {
title: 'Give failed',
description :
'You need to have permission to manage this guild (MANAGE_GUILD)',
description: 'You need to have permission to manage this guild (MANAGE_GUILD)',
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
const user = await interaction.options.getUser('user');
const amount = await interaction.options.getInteger('amount');
@ -28,17 +26,14 @@ module.exports = async (interaction) => {
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
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) {
const embed = {
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,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
@ -56,8 +51,8 @@ module.exports = async (interaction) => {
};
await logger.debug(
`Administrator: ${interaction.user.username} gave ${
amount <= 1 ? `${amount} credit`
: `${amount} credits`} to ${user.username}`,
amount <= 1 ? `${amount} credit` : `${amount} credits`
} to ${user.username}`
);
return await interaction.editReply({ embeds: [embed], ephemeral: true });
} catch (e) {

View file

@ -19,52 +19,46 @@ module.exports = async (interaction) => {
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
const amount = await interaction.options.getInteger('amount');
// eslint-disable-next-line max-len
const user = await credits.findOne(
{userId : interaction.user.id, guildId : interaction.member.guild.id});
const dmUser =
interaction.client.users.cache.get(interaction.member.user.id);
const user = await credits.findOne({
userId: interaction.user.id,
guildId: interaction.member.guild.id,
});
const dmUser = interaction.client.users.cache.get(interaction.member.user.id);
if ((amount || user.balance) < 100) {
const embed = {
title: 'Redeem',
description :
`You can't redeem below 100. Your balance is ${user.balance}.`,
description: `You can't redeem below 100. Your balance is ${user.balance}.`,
color: config.colors.error,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
if ((amount || user.balance) > 1000000) {
const embed = {
title: 'Redeem',
description :
`You can't redeem over 1,000,000. Your balance is ${user.balance}.`,
description: `You can't redeem over 1,000,000. Your balance is ${user.balance}.`,
color: config.colors.error,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
if (user.balance < amount) {
const embed = {
title: 'Redeem',
description :
`You have insufficient credits. Your balance is ${user.balance}.`,
description: `You have insufficient credits. Your balance is ${user.balance}.`,
color: config.colors.error,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
const code = uuidv4();
@ -85,8 +79,7 @@ module.exports = async (interaction) => {
.then(async () => {
const dmEmbed = {
title: 'Redeem',
description : `Your new balance is ${
user.balance - (amount || user.balance)}.`,
description: `Your new balance is ${user.balance - (amount || user.balance)}.`,
fields: [
{ name: 'Code', value: `${code}`, inline: true },
{
@ -110,11 +103,9 @@ module.exports = async (interaction) => {
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 interaction.editReply(
{embeds : [ interactionEmbed ], ephemeral : true});
await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
})
.catch(async (e) => {
await logger.error(e);

View file

@ -22,11 +22,9 @@ module.exports = async (interaction) => {
guild.credits.token = token !== null ? token : guild.credits.token;
guild.credits.rate = rate !== null ? rate : guild.credits.rate;
guild.credits.timeout = timeout !== null ? timeout : guild.credits.timeout;
guild.credits.workRate =
workRate !== null ? workRate : guild.credits.workRate;
guild.credits.workRate = workRate !== null ? workRate : guild.credits.workRate;
// eslint-disable-next-line max-len
guild.credits.workTimeout =
workTimeout !== null ? workTimeout : guild.credits.workTimeout;
guild.credits.workTimeout = workTimeout !== null ? workTimeout : guild.credits.workTimeout;
// eslint-disable-next-line max-len
guild.credits.minimumLength =
minimumLength !== null ? minimumLength : guild.credits.minimumLength;
@ -40,21 +38,23 @@ module.exports = async (interaction) => {
{ name: 'Status', value: `${guild.credits.status}`, inline: true },
{ name: 'URL', value: `${guild.credits.url}`, inline: true },
{ name: 'Token', value: `${guild.credits.token}` },
{name : 'Rate', value : `${guild.credits.rate}`, inline : true}, {
{ name: 'Rate', value: `${guild.credits.rate}`, inline: true },
{
name: 'Minimum Length',
value: `${guild.credits.minimumLength}`,
inline : true
inline: true,
},
{name : 'Timeout', value : `${guild.credits.timeout}`, inline : true}, {
{ name: 'Timeout', value: `${guild.credits.timeout}`, inline: true },
{
name: 'Work Rate',
value: `${guild.credits.workRate}`,
inline : true
inline: true,
},
{
name: 'Work Timeout',
value: `${guild.credits.workTimeout}`,
inline : true
}
inline: true,
},
],
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },

View file

@ -12,27 +12,25 @@ module.exports = async (interaction) => {
if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
const embed = {
title: 'Transfer failed',
description :
'You need to have permission to manage this guild (MANAGE_GUILD)',
description: 'You need to have permission to manage this guild (MANAGE_GUILD)',
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
const from = await interaction.options.getUser('from');
const to = await interaction.options.getUser('to');
const amount = await interaction.options.getInteger('amount');
// eslint-disable-next-line max-len
const fromUser = await credits.findOne(
{userId : from.id, guildId : interaction.member.guild.id});
const toUser = await credits.findOne(
{userId : to.id, guildId : interaction.member.guild.id});
const fromUser = await credits.findOne({
userId: from.id,
guildId: interaction.member.guild.id,
});
const toUser = await credits.findOne({ userId: to.id, guildId: interaction.member.guild.id });
if (!fromUser) {
const embed = {
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,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
@ -43,8 +41,7 @@ module.exports = async (interaction) => {
if (!toUser) {
const embed = {
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,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
@ -60,20 +57,17 @@ module.exports = async (interaction) => {
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
if (fromUser.balance < amount) {
const embed = {
title: 'Transfer',
description : `${from.username} has insufficient credits. ${
from.username} balance is ${fromUser.balance}`,
description: `${from.username} has insufficient credits. ${from.username} balance is ${fromUser.balance}`,
color: 0xbb2124,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return await interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return await interaction.editReply({ embeds: [embed], ephemeral: true });
}
fromUser.balance -= amount;
@ -89,20 +83,19 @@ module.exports = async (interaction) => {
{
name: `${from.username} Balance`,
value: `${fromUser.balance}`,
inline : true
inline: true,
},
{
name: `${to.username} Balance`,
value: `${toUser.balance}`,
inline : true
inline: true,
},
],
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
await logger.debug(
`Gift sent from: ${interaction.user.username} to: ${to.username}`);
await logger.debug(`Gift sent from: ${interaction.user.username} to: ${to.username}`);
return await interaction.editReply({ embeds: [embed], ephemeral: true });
} catch (e) {
logger.error(e);

View file

@ -16,10 +16,10 @@ module.exports = async (interaction) => {
.findOneAndUpdate(
{
userId: interaction.member.id,
guildId : interaction.member.guild.id
guildId: interaction.member.guild.id,
},
{ $inc: { balance: creditsEarned } },
{new : true, upsert : true},
{ new: true, upsert: true }
)
.then(async () => {
logger.debug(`Credits added to user: ${interaction.member.id}`);
@ -28,32 +28,35 @@ module.exports = async (interaction) => {
description: `You earned ${creditNoun(creditsEarned)}`,
color: config.colors.success,
timestamp: new Date(),
footer :
{iconURL : config.footer.icon, text : config.footer.text},
footer: { iconURL: config.footer.icon, text: config.footer.text },
};
return interaction.editReply(
{embeds : [ embed ], ephemeral : true});
return interaction.editReply({ embeds: [embed], ephemeral: true });
})
.catch(async (err) => { await logger.error(err); });
.catch(async (err) => {
await logger.error(err);
});
workedRecently.add(interaction.member.id);
setTimeout(() => {
logger.debug(
`User: ${interaction.member.id} has not worked within last ${
guild.credits.workTimeout / 1000} seconds, work can be runned`,
guild.credits.workTimeout / 1000
} seconds, work can be runned`
);
workedRecently.delete(interaction.member.id);
}, guild.credits.timeout);
} else {
logger.debug(
`User: ${interaction.member.id} has already worked within last ${
guild.credits.workTimeout / 1000} seconds, no work is runned`,
guild.credits.workTimeout / 1000
} seconds, no work is runned`
);
const embed = {
title: 'Work',
description: `You can not work now, wait ${
guild.credits.workTimeout / 1000} seconds until timeout is out.`,
guild.credits.workTimeout / 1000
} seconds until timeout is out.`,
color: config.colors.error,
timestamp: new Date(),
footer: { iconURL: config.footer.icon, text: config.footer.text },

View file

@ -22,147 +22,128 @@ module.exports = {
]),
guildOnly: true,
botAdminOnly: false,
data :
new SlashCommandBuilder()
data: new SlashCommandBuilder()
.setName('credits')
.setDescription('Manage your credits.')
.addSubcommand(
(subcommand) =>
subcommand.setName('give')
.addSubcommand((subcommand) =>
subcommand
.setName('give')
.setDescription('Give credits to a user. (ADMIN)')
.addUserOption(
(option) =>
option.setName('user')
.setDescription('The user you want to pay.')
.setRequired(true))
.addIntegerOption(
(option) =>
option.setName('amount')
.setDescription('The amount you will pay.')
.setRequired(true)))
.addSubcommand(
(subcommand) =>
subcommand.setName('take')
.addUserOption((option) =>
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
)
.addIntegerOption((option) =>
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
)
)
.addSubcommand((subcommand) =>
subcommand
.setName('take')
.setDescription('Take credits from a user. (ADMIN)')
.addUserOption(
(option) =>
option.setName('user')
.setDescription(
'The user you want to take credits from.')
.setRequired(true))
.addIntegerOption(
(option) =>
option.setName('amount')
.setDescription('The amount you will take.')
.setRequired(true)))
.addSubcommand(
(subcommand) =>
subcommand.setName('balance')
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user you want to take credits from.')
.setRequired(true)
)
.addIntegerOption((option) =>
option.setName('amount').setDescription('The amount you will take.').setRequired(true)
)
)
.addSubcommand((subcommand) =>
subcommand
.setName('balance')
.setDescription("Check a user's balance.")
.addUserOption(
(option) =>
option.setName('user')
.setDescription(
'The user whose balance you want to check.')
.setRequired(false)))
.addSubcommand(
(subcommand) =>
subcommand.setName('redeem')
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user whose balance you want to check.')
.setRequired(false)
)
)
.addSubcommand((subcommand) =>
subcommand
.setName('redeem')
.setDescription('Redeem your credits.')
.addIntegerOption(
(option) => option.setName('amount').setDescription(
'How much credit you want to withdraw.')))
.addSubcommand(
(subcommand) =>
subcommand.setName('gift')
.addIntegerOption((option) =>
option.setName('amount').setDescription('How much credit you want to withdraw.')
)
)
.addSubcommand((subcommand) =>
subcommand
.setName('gift')
.setDescription('Gift someone credits from your credits.')
.addUserOption(
(option) =>
option.setName('user')
.setDescription('The user you want to pay.')
.setRequired(true))
.addIntegerOption(
(option) =>
option.setName('amount')
.setDescription('The amount you will pay.')
.setRequired(true))
.addStringOption(
(option) => option.setName('reason').setDescription(
'Your reason.')))
.addUserOption((option) =>
option.setName('user').setDescription('The user you want to pay.').setRequired(true)
)
.addIntegerOption((option) =>
option.setName('amount').setDescription('The amount you will pay.').setRequired(true)
)
.addStringOption((option) => option.setName('reason').setDescription('Your reason.'))
)
.addSubcommand((subcommand) =>
subcommand.setName('top').setDescription(
'Check the top balance.'))
.addSubcommand(
(subcommand) =>
subcommand.setName('transfer')
.setDescription(
'Transfer credits from a user to another user. (ADMIN)')
.addUserOption(
(option) =>
option.setName('from')
.setDescription(
'The user you want to take credits from.')
.setRequired(true))
.addUserOption(
(option) =>
option.setName('to')
.setDescription(
'The user you want to give credits to.')
.setRequired(true))
.addIntegerOption(
(option) => option.setName('amount')
.setDescription(
'The amount you will transfer.')
.setRequired(true)))
.addSubcommand(
(subcommand) =>
subcommand.setName('set')
subcommand.setName('top').setDescription('Check the top balance.')
)
.addSubcommand((subcommand) =>
subcommand
.setName('transfer')
.setDescription('Transfer credits from a user to another user. (ADMIN)')
.addUserOption((option) =>
option
.setName('from')
.setDescription('The user you want to take credits from.')
.setRequired(true)
)
.addUserOption((option) =>
option
.setName('to')
.setDescription('The user you want to give credits to.')
.setRequired(true)
)
.addIntegerOption((option) =>
option.setName('amount').setDescription('The amount you will transfer.').setRequired(true)
)
)
.addSubcommand((subcommand) =>
subcommand
.setName('set')
.setDescription('Set credits on a user. (ADMIN)')
.addUserOption(
(option) =>
option.setName('user')
.setDescription(
'The user you want to set credits on.')
.setRequired(true))
.addIntegerOption(
(option) =>
option.setName('amount')
.setDescription('The amount you will set.')
.setRequired(true)))
.addSubcommand(
(subcommand) =>
subcommand.setName('settings')
.setDescription('Manage credit settings. (ADMIN)')
.addBooleanOption(
(option) => option.setName('status').setDescription(
'Toggle credits.'))
.addStringOption((option) =>
option.setName('url').setDescription(
'Controlpanel.gg URL.'))
.addStringOption(
(option) => option.setName('token').setDescription(
'Controlpanel.gg token.'))
.addNumberOption(
(option) => option.setName('rate').setDescription(
'Credits rate.'))
.addNumberOption(
(option) => option.setName('minimum-length')
.setDescription(
'Minimum length for credits.'))
.addNumberOption(
(option) => option.setName('work-rate')
.setDescription('Work rate (rate).'))
.addNumberOption(
(option) =>
option.setName('work-timeout')
.setDescription(
'Timeout between working for credits (milliseconds).'))
.addNumberOption(
(option) => option.setName('timeout').setDescription(
'Timeout between credits (milliseconds).')))
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user you want to set credits on.')
.setRequired(true)
)
.addIntegerOption((option) =>
option.setName('amount').setDescription('The amount you will set.').setRequired(true)
)
)
.addSubcommand((subcommand) =>
subcommand.setName('work').setDescription(
'Work for credits.')),
subcommand
.setName('settings')
.setDescription('Manage credit settings. (ADMIN)')
.addBooleanOption((option) => option.setName('status').setDescription('Toggle credits.'))
.addStringOption((option) => option.setName('url').setDescription('Controlpanel.gg URL.'))
.addStringOption((option) =>
option.setName('token').setDescription('Controlpanel.gg token.')
)
.addNumberOption((option) => option.setName('rate').setDescription('Credits rate.'))
.addNumberOption((option) =>
option.setName('minimum-length').setDescription('Minimum length for credits.')
)
.addNumberOption((option) =>
option.setName('work-rate').setDescription('Work rate (rate).')
)
.addNumberOption((option) =>
option
.setName('work-timeout')
.setDescription('Timeout between working for credits (milliseconds).')
)
.addNumberOption((option) =>
option.setName('timeout').setDescription('Timeout between credits (milliseconds).')
)
)
.addSubcommand((subcommand) => subcommand.setName('work').setDescription('Work for credits.')),
async execute(interaction) {
const guild = await guilds.findOne({ guildId: interaction.member.guild.id });
@ -170,8 +151,7 @@ module.exports = {
await settings(interaction);
}
if (guild.credits.status === false &&
interaction.options.getSubcommand() !== 'settings') {
if (guild.credits.status === false && interaction.options.getSubcommand() !== 'settings') {
const embed = {
title: 'Credits',
description: 'Please enable credits by ``/credits settings``',

View file

@ -5,12 +5,14 @@ const guilds = require('../helpers/database/models/guildSchema');
module.exports = {
name: 'interactionCreate',
async execute(guild) {
const guildExist = await guilds.findOne({guildId : guild.id})
const guildExist = await guilds
.findOne({ guildId: guild.id })
.then(logger.debug(`Found guild: ${guild.id}`))
.catch(logger.error);
if (!guildExist) {
await guilds.create({guildId : guild.id})
await guilds
.create({ guildId: guild.id })
.then(() => logger.debug(`Create guild: ${guild.id} was success`))
.catch((e) => logger.error(e));
}

View file

@ -41,7 +41,7 @@ const guildSchema = new mongoose.Schema(
},
},
},
{timestamps : true},
{ timestamps: true }
);
module.exports = mongoose.model('guild', guildSchema);