[CodeFactor] Apply fixes to commit e1a49cc

This commit is contained in:
codefactor-io 2022-03-12 21:30:15 +00:00 committed by Axel Olausson Holtenäs
parent 394eae4642
commit 83501cf35e
No known key found for this signature in database
GPG key ID: E3AE7E194AE017ED
16 changed files with 173 additions and 61 deletions

View file

@ -11,7 +11,9 @@ module.exports = {
.setName('view')
.setDescription('View a profile.')
.addUserOption((option) =>
option.setName('target').setDescription('The profile you wish to view')
option
.setName('target')
.setDescription('The profile you wish to view')
)
),
async execute(interaction) {

View file

@ -35,12 +35,18 @@ module.exports = async (interaction) => {
// Build embed
const embed = {
title: i18next.t('commands:reputation:addons:give:version03:embed:title', {
lng: await user.language,
}),
description: i18next.t('commands:reputation:addons:give:version02:embed:title', {
lng: await user.language,
}),
title: i18next.t(
'commands:reputation:addons:give:version03:embed:title',
{
lng: await user.language,
}
),
description: i18next.t(
'commands:reputation:addons:give:version02:embed:title',
{
lng: await user.language,
}
),
};
// Send reply
@ -64,14 +70,20 @@ module.exports = async (interaction) => {
// Build embed
const embed = {
title: i18next.t('commands:reputation:addons:give:version02:embed:title', {
lng: await user.language,
}),
description: i18next.t('commands:reputation:addons:give:version02:embed:description', {
lng: await user.language,
user: target,
type,
}),
title: i18next.t(
'commands:reputation:addons:give:version02:embed:title',
{
lng: await user.language,
}
),
description: i18next.t(
'commands:reputation:addons:give:version02:embed:description',
{
lng: await user.language,
user: target,
type,
}
),
timestamp: new Date(),
color: config.colors.success,
footer: { iconURL: config.footer.icon, text: config.footer.text },
@ -110,12 +122,18 @@ module.exports = async (interaction) => {
}, 86400000);
} else {
const embed = {
title: i18next.t('commands:reputation:addons:give:version01:embed:title', {
lng: await user.language,
}),
description: i18next.t('commands:reputation:addons:give:version01:embed:description', {
lng: await user.language,
}),
title: i18next.t(
'commands:reputation:addons:give:version01:embed:title',
{
lng: await user.language,
}
),
description: i18next.t(
'commands:reputation:addons:give:version01:embed:description',
{
lng: await user.language,
}
),
timestamp: new Date(),
color: config.colors.error,
footer: { iconURL: config.footer.icon, text: config.footer.text },

View file

@ -13,7 +13,10 @@ module.exports = {
.setName('give')
.setDescription('Give reputation for a user')
.addUserOption((option) =>
option.setName('target').setDescription('The user you want to repute.').setRequired(true)
option
.setName('target')
.setDescription('The user you want to repute.')
.setRequired(true)
)
.addStringOption((option) =>
option

View file

@ -42,8 +42,10 @@ module.exports = async (interaction) => {
guild.credits.status = status !== null ? status : guild.credits.status;
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.workTimeout = workTimeout !== null ? workTimeout : guild.credits.workTimeout;
guild.credits.workRate =
workRate !== null ? workRate : guild.credits.workRate;
guild.credits.workTimeout =
workTimeout !== null ? workTimeout : guild.credits.workTimeout;
guild.credits.minimumLength =
minimumLength !== null ? minimumLength : guild.credits.minimumLength;
@ -86,6 +88,8 @@ module.exports = async (interaction) => {
// Send debug message
await logger.debug(`Guild: ${member.guild.id} User: ${member.id} has changed credit details.`);
await logger.debug(
`Guild: ${member.guild.id} User: ${member.id} has changed credit details.`
);
});
};

View file

@ -32,7 +32,11 @@ module.exports = async (interaction) => {
// Update API credentials
await apis
.findOneAndUpdate({ guildId: member.guild.id }, { url, token }, { new: true, upsert: true })
.findOneAndUpdate(
{ guildId: member.guild.id },
{ url, token },
{ new: true, upsert: true }
)
.then(async () => {
// Build embed

View file

@ -17,10 +17,16 @@ module.exports = {
.setName('pterodactyl')
.setDescription('Controlpanel.gg')
.addStringOption((option) =>
option.setName('url').setDescription('The api url').setRequired(true)
option
.setName('url')
.setDescription('The api url')
.setRequired(true)
)
.addStringOption((option) =>
option.setName('token').setDescription('The api token').setRequired(true)
option
.setName('token')
.setDescription('The api token')
.setRequired(true)
)
)
.addSubcommand((command) =>
@ -28,10 +34,14 @@ module.exports = {
.setName('credits')
.setDescription('Credits')
.addBooleanOption((option) =>
option.setName('status').setDescription('Should credits be enabled?')
option
.setName('status')
.setDescription('Should credits be enabled?')
)
.addNumberOption((option) =>
option.setName('rate').setDescription('Amount of credits per message.')
option
.setName('rate')
.setDescription('Amount of credits per message.')
)
.addNumberOption((option) =>
option
@ -39,17 +49,23 @@ module.exports = {
.setDescription('Minimum length of message to earn credits.')
)
.addNumberOption((option) =>
option.setName('work-rate').setDescription('Maximum amount of credits on work.')
option
.setName('work-rate')
.setDescription('Maximum amount of credits on work.')
)
.addNumberOption((option) =>
option
.setName('work-timeout')
.setDescription('Timeout between work schedules (milliseconds).')
.setDescription(
'Timeout between work schedules (milliseconds).'
)
)
.addNumberOption((option) =>
option
.setName('timeout')
.setDescription('Timeout between earning credits (milliseconds).')
.setDescription(
'Timeout between earning credits (milliseconds).'
)
)
)
)

View file

@ -24,17 +24,38 @@ module.exports = async (interaction) => {
title: 'Lookup',
fields: [
{ name: 'AS', value: `${res.data.as || 'Not available'}` },
{ name: 'Country', value: `${res.data.country || 'Not available'}` },
{ name: 'Country Code', value: `${res.data.countryCode || 'Not available'}` },
{ name: 'Region', value: `${res.data.region || 'Not available'}` },
{ name: 'Region Name', value: `${res.data.regionName || 'Not available'}` },
{
name: 'Country',
value: `${res.data.country || 'Not available'}`,
},
{
name: 'Country Code',
value: `${res.data.countryCode || 'Not available'}`,
},
{
name: 'Region',
value: `${res.data.region || 'Not available'}`,
},
{
name: 'Region Name',
value: `${res.data.regionName || 'Not available'}`,
},
{ name: 'City', value: `${res.data.city || 'Not available'}` },
{ name: 'ZIP Code', value: `${res.data.zip || 'Not available'}` },
{ name: 'Latitude', value: `${res.data.lat || 'Not available'}` },
{ name: 'Longitude', value: `${res.data.lon || 'Not available'}` },
{ name: 'Timezone', value: `${res.data.timezone || 'Not available'}` },
{
name: 'Longitude',
value: `${res.data.lon || 'Not available'}`,
},
{
name: 'Timezone',
value: `${res.data.timezone || 'Not available'}`,
},
{ name: 'ISP', value: `${res.data.isp || 'Not available'}` },
{ name: 'Organization', value: `${res.data.org || 'Not available'}` },
{
name: 'Organization',
value: `${res.data.org || 'Not available'}`,
},
],
color: config.colors.success,
timestamp: new Date(),

View file

@ -8,13 +8,16 @@ module.exports = async (interaction) => {
if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
const embed = {
title: 'Users 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 });
}
// eslint-disable-next-line max-len
const userList = await interaction.client.users.cache.filter((user) => !user.bot);
const userList = await interaction.client.users.cache.filter(
(user) => !user.bot
);
userList.map((user) => {
logger.info(user);

View file

@ -11,7 +11,9 @@ module.exports = {
.addSubcommand((subcommand) =>
subcommand
.setName('lookup')
.setDescription('Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)')
.setDescription(
'Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)'
)
.addStringOption((option) =>
option
.setName('target')

View file

@ -22,13 +22,20 @@ module.exports = async () => {
const rest = new REST({ version: '9' }).setToken(config.bot.token);
await rest.put(Routes.applicationCommands(config.bot.clientId), { body: commands });
await rest.put(Routes.applicationCommands(config.bot.clientId), {
body: commands,
});
await rest
.put(Routes.applicationGuildCommands(config.bot.clientId, config.bot.guildId), {
body: commands,
})
.then(async () => logger.info('Successfully registered application commands.'))
.put(
Routes.applicationGuildCommands(config.bot.clientId, config.bot.guildId),
{
body: commands,
}
)
.then(async () =>
logger.info('Successfully registered application commands.')
)
.catch(async (err) => {
await logger.error(err);
});

View file

@ -6,7 +6,9 @@ module.exports = {
const { client } = guild;
await guilds.findOne({ guildId: guild.id }, { new: true, upsert: true });
await client.user.setPresence({
activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }],
activities: [
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
],
status: 'online',
});
},

View file

@ -13,7 +13,10 @@ module.exports = {
if (!command) return;
await guilds.findOne({ guildId: member.guild.id }, { new: true, upsert: true });
await guilds.findOne(
{ guildId: member.guild.id },
{ new: true, upsert: true }
);
try {
await interaction.deferReply({

View file

@ -1,6 +1,12 @@
const logger = require('../handlers/logger');
const { users, guilds, experiences, credits, timeouts } = require('../helpers/database/models');
const {
users,
guilds,
experiences,
credits,
timeouts,
} = require('../helpers/database/models');
module.exports = {
name: 'messageCreate',
@ -15,7 +21,10 @@ module.exports = {
// Create user if not already created
await users.findOne({ userId: message.author.id }, { new: true, upsert: true });
await users.findOne(
{ userId: message.author.id },
{ new: true, upsert: true }
);
// Stop if message content is shorter than guild configured minimum length
@ -44,7 +53,9 @@ module.exports = {
{ new: true, upsert: true }
)
.then(async () =>
logger.debug(`Guild: ${message.guild.id} Credits added to user: ${message.author.id}`)
logger.debug(
`Guild: ${message.guild.id} Credits added to user: ${message.author.id}`
)
)
.catch(async (err) => {
await logger.error(err);
@ -59,7 +70,9 @@ module.exports = {
{ new: true, upsert: true }
)
.then(async () =>
logger.debug(`Guild: ${message.guild.id} Points added to user: ${message.author.id}`)
logger.debug(
`Guild: ${message.guild.id} Points added to user: ${message.author.id}`
)
)
.catch(async (err) => {
await logger.error(err);
@ -75,7 +88,9 @@ module.exports = {
setTimeout(async () => {
await logger.debug(
`Guild: ${message.guild.id} User: ${message.author.id} has not talked within last ${
`Guild: ${message.guild.id} User: ${
message.author.id
} has not talked within last ${
guild.credits.timeout / 1000
} seconds, credits can be given`
);
@ -90,7 +105,9 @@ module.exports = {
}, guild.credits.timeout);
} else {
await logger.debug(
`Guild: ${message.guild.id} User: ${message.author.id} has talked within last ${
`Guild: ${message.guild.id} User: ${
message.author.id
} has talked within last ${
guild.credits.timeout / 1000
} seconds, no credits given`
);

View file

@ -6,7 +6,9 @@ module.exports = {
async execute(client) {
await logger.info(`Ready! Logged in as ${client.user.tag}`);
await client.user.setPresence({
activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }],
activities: [
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
],
status: 'online',
});
},

View file

@ -32,11 +32,15 @@ module.exports = async () => {
version02: {
embed: {
title: 'Reputation',
description: 'You have given {{user}} a {{type}} reputation!',
description:
'You have given {{user}} a {{type}} reputation!',
},
},
version03: {
embed: { title: 'Reputation', description: 'You can not repute yourself.' },
embed: {
title: 'Reputation',
description: 'You can not repute yourself.',
},
},
},
},
@ -94,7 +98,10 @@ module.exports = async () => {
},
},
version03: {
embed: { title: 'Omdöme', description: 'Du kan inte ge dig själv ett omdöme.' },
embed: {
title: 'Omdöme',
description: 'Du kan inte ge dig själv ett omdöme.',
},
},
},
},

View file

@ -1 +1,2 @@
module.exports = (amount) => `${amount <= 1 ? `${amount} credit` : `${amount} credits`}`;
module.exports = (amount) =>
`${amount <= 1 ? `${amount} credit` : `${amount} credits`}`;