[CodeFactor] Apply fixes to commit e1a49cc
This commit is contained in:
parent
394eae4642
commit
83501cf35e
16 changed files with 173 additions and 61 deletions
|
@ -11,7 +11,9 @@ module.exports = {
|
||||||
.setName('view')
|
.setName('view')
|
||||||
.setDescription('View a profile.')
|
.setDescription('View a profile.')
|
||||||
.addUserOption((option) =>
|
.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) {
|
async execute(interaction) {
|
||||||
|
|
|
@ -35,12 +35,18 @@ module.exports = async (interaction) => {
|
||||||
// Build embed
|
// Build embed
|
||||||
|
|
||||||
const embed = {
|
const embed = {
|
||||||
title: i18next.t('commands:reputation:addons:give:version03:embed:title', {
|
title: i18next.t(
|
||||||
|
'commands:reputation:addons:give:version03:embed:title',
|
||||||
|
{
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
}),
|
}
|
||||||
description: i18next.t('commands:reputation:addons:give:version02:embed:title', {
|
),
|
||||||
|
description: i18next.t(
|
||||||
|
'commands:reputation:addons:give:version02:embed:title',
|
||||||
|
{
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send reply
|
// Send reply
|
||||||
|
@ -64,14 +70,20 @@ module.exports = async (interaction) => {
|
||||||
// Build embed
|
// Build embed
|
||||||
|
|
||||||
const embed = {
|
const embed = {
|
||||||
title: i18next.t('commands:reputation:addons:give:version02:embed:title', {
|
title: i18next.t(
|
||||||
|
'commands:reputation:addons:give:version02:embed:title',
|
||||||
|
{
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
}),
|
}
|
||||||
description: i18next.t('commands:reputation:addons:give:version02:embed:description', {
|
),
|
||||||
|
description: i18next.t(
|
||||||
|
'commands:reputation:addons:give:version02:embed:description',
|
||||||
|
{
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
user: target,
|
user: target,
|
||||||
type,
|
type,
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
color: config.colors.success,
|
color: config.colors.success,
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
@ -110,12 +122,18 @@ module.exports = async (interaction) => {
|
||||||
}, 86400000);
|
}, 86400000);
|
||||||
} else {
|
} else {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: i18next.t('commands:reputation:addons:give:version01:embed:title', {
|
title: i18next.t(
|
||||||
|
'commands:reputation:addons:give:version01:embed:title',
|
||||||
|
{
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
}),
|
}
|
||||||
description: i18next.t('commands:reputation:addons:give:version01:embed:description', {
|
),
|
||||||
|
description: i18next.t(
|
||||||
|
'commands:reputation:addons:give:version01:embed:description',
|
||||||
|
{
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
color: config.colors.error,
|
color: config.colors.error,
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
|
|
@ -13,7 +13,10 @@ module.exports = {
|
||||||
.setName('give')
|
.setName('give')
|
||||||
.setDescription('Give reputation for a user')
|
.setDescription('Give reputation for a user')
|
||||||
.addUserOption((option) =>
|
.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) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
|
|
|
@ -42,8 +42,10 @@ module.exports = async (interaction) => {
|
||||||
guild.credits.status = status !== null ? status : guild.credits.status;
|
guild.credits.status = status !== null ? status : guild.credits.status;
|
||||||
guild.credits.rate = rate !== null ? rate : guild.credits.rate;
|
guild.credits.rate = rate !== null ? rate : guild.credits.rate;
|
||||||
guild.credits.timeout = timeout !== null ? timeout : guild.credits.timeout;
|
guild.credits.timeout = timeout !== null ? timeout : guild.credits.timeout;
|
||||||
guild.credits.workRate = workRate !== null ? workRate : guild.credits.workRate;
|
guild.credits.workRate =
|
||||||
guild.credits.workTimeout = workTimeout !== null ? workTimeout : guild.credits.workTimeout;
|
workRate !== null ? workRate : guild.credits.workRate;
|
||||||
|
guild.credits.workTimeout =
|
||||||
|
workTimeout !== null ? workTimeout : guild.credits.workTimeout;
|
||||||
guild.credits.minimumLength =
|
guild.credits.minimumLength =
|
||||||
minimumLength !== null ? minimumLength : guild.credits.minimumLength;
|
minimumLength !== null ? minimumLength : guild.credits.minimumLength;
|
||||||
|
|
||||||
|
@ -86,6 +88,8 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
// Send debug message
|
// 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.`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,11 @@ module.exports = async (interaction) => {
|
||||||
// Update API credentials
|
// Update API credentials
|
||||||
|
|
||||||
await apis
|
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 () => {
|
.then(async () => {
|
||||||
// Build embed
|
// Build embed
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,16 @@ module.exports = {
|
||||||
.setName('pterodactyl')
|
.setName('pterodactyl')
|
||||||
.setDescription('Controlpanel.gg')
|
.setDescription('Controlpanel.gg')
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option.setName('url').setDescription('The api url').setRequired(true)
|
option
|
||||||
|
.setName('url')
|
||||||
|
.setDescription('The api url')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option.setName('token').setDescription('The api token').setRequired(true)
|
option
|
||||||
|
.setName('token')
|
||||||
|
.setDescription('The api token')
|
||||||
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addSubcommand((command) =>
|
.addSubcommand((command) =>
|
||||||
|
@ -28,10 +34,14 @@ module.exports = {
|
||||||
.setName('credits')
|
.setName('credits')
|
||||||
.setDescription('Credits')
|
.setDescription('Credits')
|
||||||
.addBooleanOption((option) =>
|
.addBooleanOption((option) =>
|
||||||
option.setName('status').setDescription('Should credits be enabled?')
|
option
|
||||||
|
.setName('status')
|
||||||
|
.setDescription('Should credits be enabled?')
|
||||||
)
|
)
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option.setName('rate').setDescription('Amount of credits per message.')
|
option
|
||||||
|
.setName('rate')
|
||||||
|
.setDescription('Amount of credits per message.')
|
||||||
)
|
)
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option
|
option
|
||||||
|
@ -39,17 +49,23 @@ module.exports = {
|
||||||
.setDescription('Minimum length of message to earn credits.')
|
.setDescription('Minimum length of message to earn credits.')
|
||||||
)
|
)
|
||||||
.addNumberOption((option) =>
|
.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) =>
|
.addNumberOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('work-timeout')
|
.setName('work-timeout')
|
||||||
.setDescription('Timeout between work schedules (milliseconds).')
|
.setDescription(
|
||||||
|
'Timeout between work schedules (milliseconds).'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.addNumberOption((option) =>
|
.addNumberOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('timeout')
|
.setName('timeout')
|
||||||
.setDescription('Timeout between earning credits (milliseconds).')
|
.setDescription(
|
||||||
|
'Timeout between earning credits (milliseconds).'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,17 +24,38 @@ module.exports = async (interaction) => {
|
||||||
title: 'Lookup',
|
title: 'Lookup',
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'AS', value: `${res.data.as || 'Not available'}` },
|
{ 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: 'Country',
|
||||||
{ name: 'Region', value: `${res.data.region || 'Not available'}` },
|
value: `${res.data.country || 'Not available'}`,
|
||||||
{ name: 'Region Name', value: `${res.data.regionName || '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: 'City', value: `${res.data.city || 'Not available'}` },
|
||||||
{ name: 'ZIP Code', value: `${res.data.zip || 'Not available'}` },
|
{ name: 'ZIP Code', value: `${res.data.zip || 'Not available'}` },
|
||||||
{ name: 'Latitude', value: `${res.data.lat || '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: '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,
|
color: config.colors.success,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
|
|
|
@ -8,13 +8,16 @@ module.exports = async (interaction) => {
|
||||||
if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
|
if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Users failed',
|
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 });
|
return await interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// 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) => {
|
userList.map((user) => {
|
||||||
logger.info(user);
|
logger.info(user);
|
||||||
|
|
|
@ -11,7 +11,9 @@ module.exports = {
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName('lookup')
|
.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) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('target')
|
.setName('target')
|
||||||
|
|
|
@ -22,13 +22,20 @@ module.exports = async () => {
|
||||||
|
|
||||||
const rest = new REST({ version: '9' }).setToken(config.bot.token);
|
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
|
await rest
|
||||||
.put(Routes.applicationGuildCommands(config.bot.clientId, config.bot.guildId), {
|
.put(
|
||||||
|
Routes.applicationGuildCommands(config.bot.clientId, config.bot.guildId),
|
||||||
|
{
|
||||||
body: commands,
|
body: commands,
|
||||||
})
|
}
|
||||||
.then(async () => logger.info('Successfully registered application commands.'))
|
)
|
||||||
|
.then(async () =>
|
||||||
|
logger.info('Successfully registered application commands.')
|
||||||
|
)
|
||||||
.catch(async (err) => {
|
.catch(async (err) => {
|
||||||
await logger.error(err);
|
await logger.error(err);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,9 @@ module.exports = {
|
||||||
const { client } = guild;
|
const { client } = guild;
|
||||||
await guilds.findOne({ guildId: guild.id }, { new: true, upsert: true });
|
await guilds.findOne({ guildId: guild.id }, { new: true, upsert: true });
|
||||||
await client.user.setPresence({
|
await client.user.setPresence({
|
||||||
activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }],
|
activities: [
|
||||||
|
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
|
||||||
|
],
|
||||||
status: 'online',
|
status: 'online',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,10 @@ module.exports = {
|
||||||
|
|
||||||
if (!command) return;
|
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 {
|
try {
|
||||||
await interaction.deferReply({
|
await interaction.deferReply({
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
const logger = require('../handlers/logger');
|
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 = {
|
module.exports = {
|
||||||
name: 'messageCreate',
|
name: 'messageCreate',
|
||||||
|
@ -15,7 +21,10 @@ module.exports = {
|
||||||
|
|
||||||
// Create user if not already created
|
// 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
|
// Stop if message content is shorter than guild configured minimum length
|
||||||
|
|
||||||
|
@ -44,7 +53,9 @@ module.exports = {
|
||||||
{ new: true, upsert: true }
|
{ new: true, upsert: true }
|
||||||
)
|
)
|
||||||
.then(async () =>
|
.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) => {
|
.catch(async (err) => {
|
||||||
await logger.error(err);
|
await logger.error(err);
|
||||||
|
@ -59,7 +70,9 @@ module.exports = {
|
||||||
{ new: true, upsert: true }
|
{ new: true, upsert: true }
|
||||||
)
|
)
|
||||||
.then(async () =>
|
.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) => {
|
.catch(async (err) => {
|
||||||
await logger.error(err);
|
await logger.error(err);
|
||||||
|
@ -75,7 +88,9 @@ module.exports = {
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await logger.debug(
|
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
|
guild.credits.timeout / 1000
|
||||||
} seconds, credits can be given`
|
} seconds, credits can be given`
|
||||||
);
|
);
|
||||||
|
@ -90,7 +105,9 @@ module.exports = {
|
||||||
}, guild.credits.timeout);
|
}, guild.credits.timeout);
|
||||||
} else {
|
} else {
|
||||||
await logger.debug(
|
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
|
guild.credits.timeout / 1000
|
||||||
} seconds, no credits given`
|
} seconds, no credits given`
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,9 @@ module.exports = {
|
||||||
async execute(client) {
|
async execute(client) {
|
||||||
await logger.info(`Ready! Logged in as ${client.user.tag}`);
|
await logger.info(`Ready! Logged in as ${client.user.tag}`);
|
||||||
await client.user.setPresence({
|
await client.user.setPresence({
|
||||||
activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }],
|
activities: [
|
||||||
|
{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` },
|
||||||
|
],
|
||||||
status: 'online',
|
status: 'online',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,11 +32,15 @@ module.exports = async () => {
|
||||||
version02: {
|
version02: {
|
||||||
embed: {
|
embed: {
|
||||||
title: 'Reputation',
|
title: 'Reputation',
|
||||||
description: 'You have given {{user}} a {{type}} reputation!',
|
description:
|
||||||
|
'You have given {{user}} a {{type}} reputation!',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
version03: {
|
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: {
|
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.',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
module.exports = (amount) => `${amount <= 1 ? `${amount} credit` : `${amount} credits`}`;
|
module.exports = (amount) =>
|
||||||
|
`${amount <= 1 ? `${amount} credit` : `${amount} credits`}`;
|
||||||
|
|
Loading…
Add table
Reference in a new issue