🌐 /reputation give: now supports languages
This commit is contained in:
parent
f3b34e0bfe
commit
dfc5b297b2
3 changed files with 113 additions and 35 deletions
|
@ -14,15 +14,17 @@ module.exports = async (interaction) => {
|
|||
const target = await interaction.options.getUser('target');
|
||||
const type = await interaction.options.getString('type');
|
||||
|
||||
// Get user object
|
||||
|
||||
const user = await users.findOne({ userId: interaction.member.id });
|
||||
|
||||
// Check if user has a timeout
|
||||
|
||||
const isTimeout = await timeouts.findOne(
|
||||
{
|
||||
guildId: member.guild.id,
|
||||
userId: member.id,
|
||||
timeoutId: 2,
|
||||
},
|
||||
);
|
||||
const isTimeout = await timeouts.findOne({
|
||||
guildId: member.guild.id,
|
||||
userId: member.id,
|
||||
timeoutId: 2,
|
||||
});
|
||||
|
||||
// If user is not on timeout
|
||||
|
||||
|
@ -30,23 +32,30 @@ module.exports = async (interaction) => {
|
|||
// Do not allow self reputation
|
||||
|
||||
if (target.id === interaction.member.id) {
|
||||
// Build embed
|
||||
// Build embed
|
||||
|
||||
const embed = { title: 'Reputation', description: 'You can not repute yourself' };
|
||||
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,
|
||||
}),
|
||||
};
|
||||
|
||||
// Send reply
|
||||
|
||||
return interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
// Get user object
|
||||
|
||||
const user = await users.findOne({ userId: interaction.member.id });
|
||||
|
||||
// Math operators depending on type of reputation
|
||||
|
||||
if (type === 'positive') { user.reputation += 1; }
|
||||
if (type === 'negative') { user.reputation -= 1; }
|
||||
if (type === 'positive') {
|
||||
user.reputation += 1;
|
||||
}
|
||||
if (type === 'negative') {
|
||||
user.reputation -= 1;
|
||||
}
|
||||
|
||||
// Save user
|
||||
|
||||
|
@ -55,8 +64,14 @@ module.exports = async (interaction) => {
|
|||
// Build embed
|
||||
|
||||
const embed = {
|
||||
title: 'Reputation',
|
||||
description: `You have given ${target} a ${type} reputation!`,
|
||||
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 },
|
||||
|
@ -68,17 +83,17 @@ module.exports = async (interaction) => {
|
|||
|
||||
// Send debug message
|
||||
|
||||
await logger.debug(`Guild: ${member.guild.id} User: ${member.id} has given ${target.id} a ${type} reputation.`);
|
||||
await logger.debug(
|
||||
`Guild: ${member.guild.id} User: ${member.id} has given ${target.id} a ${type} reputation.`,
|
||||
);
|
||||
|
||||
// Create a timeout for the user
|
||||
|
||||
await timeouts.create(
|
||||
{
|
||||
guildId: member.guild.id,
|
||||
userId: member.id,
|
||||
timeoutId: 2,
|
||||
},
|
||||
);
|
||||
await timeouts.create({
|
||||
guildId: member.guild.id,
|
||||
userId: member.id,
|
||||
timeoutId: 2,
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
await logger.debug(
|
||||
|
@ -95,8 +110,12 @@ module.exports = async (interaction) => {
|
|||
}, 86400000);
|
||||
} else {
|
||||
const embed = {
|
||||
title: 'Reputation',
|
||||
description: 'You have given reputation within the last day, you can not repute now!',
|
||||
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 },
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = {
|
|||
.setName('language')
|
||||
.setDescription('Configure your language')
|
||||
.addChoice('English', 'en')
|
||||
.addChoice('Swedish', 'se')))),
|
||||
.addChoice('Swedish', 'sv')))),
|
||||
async execute(interaction) {
|
||||
if (interaction.options.getSubcommandGroup() === 'guild') {
|
||||
await guild(interaction);
|
||||
|
|
|
@ -14,38 +14,97 @@ module.exports = async () => {
|
|||
credits_one: '{{count}} credit',
|
||||
credits_other: '{{count}} credits',
|
||||
},
|
||||
addons: { balance: { embed: { title: 'Credits' } }, gift: { embed: { title: 'Gift' } } },
|
||||
addons: {
|
||||
balance: { embed: { title: 'Credits' } },
|
||||
gift: { embed: { title: 'Gift' } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
addons: {
|
||||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: 'Reputation',
|
||||
description:
|
||||
'You have given reputation within the last day, you can not repute now!',
|
||||
},
|
||||
},
|
||||
version02: { embed: { title: 'Reputation', description: 'You have given {{user}} a {{type}} reputation!' } },
|
||||
version03: { embed: { title: 'Reputation', description: 'You can not repute yourself.' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
profile: {
|
||||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: 'Profile', reputation: 'Reputation (Global)', level: 'Level (Global)', points: 'Points (Global)', credits: 'Credits (Guild)', language_code: 'Language Code (Global)',
|
||||
title: 'Profile',
|
||||
reputation: 'Reputation (Global)',
|
||||
level: 'Level (Global)',
|
||||
points: 'Points (Global)',
|
||||
credits: 'Credits (Guild)',
|
||||
language_code: 'Language Code (Global)',
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: 'Profile',
|
||||
description: 'Following settings is set',
|
||||
fields: { language: 'Language' },
|
||||
},
|
||||
},
|
||||
settings: { embed: { title: 'Profile', description: 'Following settings is set', fields: { language: 'Language' } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
sv: {
|
||||
general: { not_available: 'Ej tillgängligt' },
|
||||
general: { not_available: 'Otillgänglig' },
|
||||
commands: {
|
||||
credits: {
|
||||
general: {
|
||||
credits_one: '{{count}} krona',
|
||||
credits_other: '{{count}} kronor',
|
||||
},
|
||||
addons: { balance: { embed: { title: 'Krediter' } }, gift: { embed: { title: 'Gåva' } } },
|
||||
addons: {
|
||||
balance: { embed: { title: 'Krediter' } },
|
||||
gift: { embed: { title: 'Gåva' } },
|
||||
},
|
||||
},
|
||||
reputation: {
|
||||
addons: {
|
||||
give: {
|
||||
version01: {
|
||||
embed: {
|
||||
title: 'Omdöme',
|
||||
description:
|
||||
'Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!',
|
||||
},
|
||||
},
|
||||
version02: { embed: { title: 'Omdöme', description: 'Du har gett {{user}} ett {{type}} omdöme!' } },
|
||||
version03: { embed: { title: 'Omdöme', description: 'Du kan inte ge dig själv ett omdöme.' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
profile: {
|
||||
addons: {
|
||||
view: {
|
||||
embed: {
|
||||
title: 'Profil', reputation: 'Omdöme (Globalt)', level: 'Nivå (Globalt)', points: 'Poäng (Globalt)', credits: 'Krediter (Server)', language_code: 'Språkkod (Globalt)',
|
||||
title: 'Profil',
|
||||
reputation: 'Omdöme (Globalt)',
|
||||
level: 'Nivå (Globalt)',
|
||||
points: 'Poäng (Globalt)',
|
||||
credits: 'Krediter (Server)',
|
||||
language_code: 'Språkkod (Globalt)',
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
embed: {
|
||||
title: 'Profil',
|
||||
description: 'Följande inställningar är satta',
|
||||
fields: { language: 'Språk' },
|
||||
},
|
||||
},
|
||||
settings: { embed: { title: 'Profil', description: 'Följande inställningar är satta', fields: { language: 'Språk' } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue