mirror of
https://github.com/Sneed-Group/clanrocket-2
synced 2025-01-09 17:53:13 +00:00
Upload files to ''
This commit is contained in:
parent
6f84082377
commit
fc977ac479
2 changed files with 168 additions and 167 deletions
15
index.js
15
index.js
|
@ -77,8 +77,8 @@ client.on('messageCreate', async message => {
|
||||||
// Increment XP every 10 messages
|
// Increment XP every 10 messages
|
||||||
if (message.guild) {
|
if (message.guild) {
|
||||||
const guildId = message.guild.id;
|
const guildId = message.guild.id;
|
||||||
const xp = db.get(`xp.${guildId}.${message.author.id}`) || 0;
|
const xp = await db.get(`xp.${guildId}.${message.author.id}`) || 0;
|
||||||
db.set(`xp.${guildId}.${message.author.id}`, xp + 1);
|
await db.set(`xp.${guildId}.${message.author.id}`, xp + 1);
|
||||||
|
|
||||||
// Check if user leveled up
|
// Check if user leveled up
|
||||||
const level = Math.floor(xp / 5) + 1;
|
const level = Math.floor(xp / 5) + 1;
|
||||||
|
@ -107,7 +107,8 @@ client.on('interactionCreate', async interaction => {
|
||||||
const guildId = interactionGuildId;
|
const guildId = interactionGuildId;
|
||||||
const user = options.getUser('user') || interaction.user;
|
const user = options.getUser('user') || interaction.user;
|
||||||
const xp = await db.get(`xp.${guildId}.${user.id}`) || 0;
|
const xp = await db.get(`xp.${guildId}.${user.id}`) || 0;
|
||||||
interaction.reply(`${user.username} has ${xp} XP.`);
|
console.log(xp)
|
||||||
|
await interaction.reply(`${user.username} has ${xp} XP.`);
|
||||||
} else if (commandName === 'addxp') {
|
} else if (commandName === 'addxp') {
|
||||||
if (!interaction.member.permissions.has('ADMINISTRATOR')) {
|
if (!interaction.member.permissions.has('ADMINISTRATOR')) {
|
||||||
return interaction.reply('You do not have permission to use this command.');
|
return interaction.reply('You do not have permission to use this command.');
|
||||||
|
@ -117,8 +118,8 @@ client.on('interactionCreate', async interaction => {
|
||||||
const amount = options.getInteger('amount');
|
const amount = options.getInteger('amount');
|
||||||
const user = options.getUser('user') || interaction.user;
|
const user = options.getUser('user') || interaction.user;
|
||||||
const currentXp = await db.get(`xp.${guildId}.${user.id}`) || 0;
|
const currentXp = await db.get(`xp.${guildId}.${user.id}`) || 0;
|
||||||
await db.set(`xp.${guildId}.${user.id}`, currentXp + amount);
|
await db.set(`xp.${guildId}.${user.id}`, currentXp + amount)
|
||||||
interaction.reply(`${amount} XP added to ${user.username}.`);
|
await interaction.reply(`${amount} XP added to ${user.username}.`);
|
||||||
} else if (commandName === 'removexp') {
|
} else if (commandName === 'removexp') {
|
||||||
if (!interaction.member.permissions.has('ADMINISTRATOR')) {
|
if (!interaction.member.permissions.has('ADMINISTRATOR')) {
|
||||||
return interaction.reply('You do not have permission to use this command.');
|
return interaction.reply('You do not have permission to use this command.');
|
||||||
|
@ -127,9 +128,9 @@ client.on('interactionCreate', async interaction => {
|
||||||
const guildId = interactionGuildId;
|
const guildId = interactionGuildId;
|
||||||
const amount = options.getInteger('amount');
|
const amount = options.getInteger('amount');
|
||||||
const user = options.getUser('user') || interaction.user;
|
const user = options.getUser('user') || interaction.user;
|
||||||
const currentXp = db.get(`xp.${guildId}.${user.id}`) || 0;
|
const currentXp = await db.get(`xp.${guildId}.${user.id}`) || 0;
|
||||||
await db.set(`xp.${guildId}.${user.id}`, Math.max(0, currentXp - amount));
|
await db.set(`xp.${guildId}.${user.id}`, Math.max(0, currentXp - amount));
|
||||||
interaction.reply(`${amount} XP removed from ${user.username}.`);
|
await interaction.reply(`${amount} XP removed from ${user.username}.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "ClanRocket",
|
"name": "clanrocket",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Discord bot for managing XP in a clan server",
|
"description": "Discord bot for managing XP in a clan server",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
@ -14,6 +14,6 @@
|
||||||
"discord.js": "^13.4.1",
|
"discord.js": "^13.4.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"quick.db": "^7.1.3"
|
"quick.db": "^9.1.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue