🌐 /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 target = await interaction.options.getUser('target');
|
||||||
const type = await interaction.options.getString('type');
|
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
|
// Check if user has a timeout
|
||||||
|
|
||||||
const isTimeout = await timeouts.findOne(
|
const isTimeout = await timeouts.findOne({
|
||||||
{
|
guildId: member.guild.id,
|
||||||
guildId: member.guild.id,
|
userId: member.id,
|
||||||
userId: member.id,
|
timeoutId: 2,
|
||||||
timeoutId: 2,
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// If user is not on timeout
|
// If user is not on timeout
|
||||||
|
|
||||||
|
@ -30,23 +32,30 @@ module.exports = async (interaction) => {
|
||||||
// Do not allow self reputation
|
// Do not allow self reputation
|
||||||
|
|
||||||
if (target.id === interaction.member.id) {
|
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
|
// Send reply
|
||||||
|
|
||||||
return interaction.editReply({ embeds: [embed] });
|
return interaction.editReply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user object
|
|
||||||
|
|
||||||
const user = await users.findOne({ userId: interaction.member.id });
|
|
||||||
|
|
||||||
// Math operators depending on type of reputation
|
// Math operators depending on type of reputation
|
||||||
|
|
||||||
if (type === 'positive') { user.reputation += 1; }
|
if (type === 'positive') {
|
||||||
if (type === 'negative') { user.reputation -= 1; }
|
user.reputation += 1;
|
||||||
|
}
|
||||||
|
if (type === 'negative') {
|
||||||
|
user.reputation -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Save user
|
// Save user
|
||||||
|
|
||||||
|
@ -55,8 +64,14 @@ module.exports = async (interaction) => {
|
||||||
// Build embed
|
// Build embed
|
||||||
|
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Reputation',
|
title: i18next.t('commands:reputation:addons:give:version02:embed:title', {
|
||||||
description: `You have given ${target} a ${type} reputation!`,
|
lng: await user.language,
|
||||||
|
}),
|
||||||
|
description: i18next.t('commands:reputation:addons:give:version02:embed:description', {
|
||||||
|
lng: await user.language,
|
||||||
|
user: target,
|
||||||
|
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 },
|
||||||
|
@ -68,17 +83,17 @@ module.exports = async (interaction) => {
|
||||||
|
|
||||||
// Send debug message
|
// 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
|
// Create a timeout for the user
|
||||||
|
|
||||||
await timeouts.create(
|
await timeouts.create({
|
||||||
{
|
guildId: member.guild.id,
|
||||||
guildId: member.guild.id,
|
userId: member.id,
|
||||||
userId: member.id,
|
timeoutId: 2,
|
||||||
timeoutId: 2,
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await logger.debug(
|
await logger.debug(
|
||||||
|
@ -95,8 +110,12 @@ module.exports = async (interaction) => {
|
||||||
}, 86400000);
|
}, 86400000);
|
||||||
} else {
|
} else {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: 'Reputation',
|
title: i18next.t('commands:reputation:addons:give:version01:embed:title', {
|
||||||
description: 'You have given reputation within the last day, you can not repute now!',
|
lng: await user.language,
|
||||||
|
}),
|
||||||
|
description: i18next.t('commands:reputation:addons:give:version01:embed:description', {
|
||||||
|
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 },
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = {
|
||||||
.setName('language')
|
.setName('language')
|
||||||
.setDescription('Configure your language')
|
.setDescription('Configure your language')
|
||||||
.addChoice('English', 'en')
|
.addChoice('English', 'en')
|
||||||
.addChoice('Swedish', 'se')))),
|
.addChoice('Swedish', 'sv')))),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
if (interaction.options.getSubcommandGroup() === 'guild') {
|
if (interaction.options.getSubcommandGroup() === 'guild') {
|
||||||
await guild(interaction);
|
await guild(interaction);
|
||||||
|
|
|
@ -14,38 +14,97 @@ module.exports = async () => {
|
||||||
credits_one: '{{count}} credit',
|
credits_one: '{{count}} credit',
|
||||||
credits_other: '{{count}} credits',
|
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: {
|
profile: {
|
||||||
addons: {
|
addons: {
|
||||||
view: {
|
view: {
|
||||||
embed: {
|
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: {
|
sv: {
|
||||||
general: { not_available: 'Ej tillgängligt' },
|
general: { not_available: 'Otillgänglig' },
|
||||||
commands: {
|
commands: {
|
||||||
credits: {
|
credits: {
|
||||||
general: {
|
general: {
|
||||||
credits_one: '{{count}} krona',
|
credits_one: '{{count}} krona',
|
||||||
credits_other: '{{count}} kronor',
|
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: {
|
profile: {
|
||||||
addons: {
|
addons: {
|
||||||
view: {
|
view: {
|
||||||
embed: {
|
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