forked from Pogy-Bot/Pogy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathaniel Wood
committed
Jan 24, 2024
1 parent
9b850d8
commit 44f107e
Showing
4 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
const Command = require("../../structures/Command"); | ||
const { MessageEmbed } = require("discord.js"); | ||
const Profile = require("../../database/models/economy/profile.js"); | ||
const { createProfile } = require("../../utils/utils.js"); | ||
|
||
module.exports = class extends Command { | ||
constructor(...args) { | ||
super(...args, { | ||
name: "rob", | ||
description: "Rob someone!", | ||
category: "Economy", | ||
usage: "<user>", | ||
examples: "rob @Peter" | ||
}) | ||
} | ||
async run(message, args) { | ||
const user = message.mentions.members.first(); | ||
const profile = await Profile.findOne({ userID: message.author.id, guildId: message.guild.id }); | ||
if(!profile) { | ||
await createProfile(user, message.guild); | ||
await message.channel.sendCustom({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("BLURPLE") | ||
.setDescription(`Creating profile.\nUse this command again to use it.`) | ||
] | ||
}); | ||
} else { | ||
if (!profile.lastMonthly) { | ||
await Profile.updateOne( | ||
{ userID: message.author.id, guildId: message.guild.id }, { $set: { lastMonthly: Date.now() } } | ||
); | ||
let amount = Math.floor(Math.random() * profile.wallet); | ||
await Profile.updateOne({ | ||
userID: user.id, | ||
guildId: message.guild.id, | ||
}, { $inc: { wallet: -amount }}); | ||
await Profile.updateOne({ | ||
userID: message.author.id, | ||
guildId: message.guild.id, | ||
}, { $inc: { wallet: amount } }); | ||
|
||
await message.channel.sendCustom({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setDescription(`Successfully robbed ${user} for $${amount}.`) | ||
.setColor(this.client.color.green) | ||
.setTimestamp() | ||
] | ||
}) | ||
} else if (Date.now - profile.lastRobbed > 600000) { | ||
await Profile.updateOne( | ||
{ userID: message.author.id, guildId: message.guild.id }, { $set: { lastMonthly: Date.now() } } | ||
); | ||
let amount = Math.floor(Math.random() * profile.wallet); | ||
await Profile.updateOne({ | ||
userID: user.id, | ||
guildId: message.guild.id, | ||
}, { $inc: { wallet: -amount }}); | ||
await Profile.updateOne({ | ||
userID: message.author.id, | ||
guildId: message.guild.id, | ||
}, { $inc: { wallet: amount } }); | ||
|
||
await message.channel.sendCustom({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setDescription(`Successfully robbed ${user} for $${amount}.`) | ||
.setColor(this.client.color.green) | ||
.setTimestamp() | ||
] | ||
}) | ||
} else { | ||
const lastRobbed = new Date(profile.lastRobbed); | ||
const timeLeft = Math.round((lastRobbed.getTime() + 600000 - Date.now()) / 1000); | ||
const minutes = Math.floor(timeLeft / 60); | ||
const seconds = timeLeft - minutes * 60; | ||
await message.channel.sendCustom({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("BLURPLE") | ||
.setTitle(`${message.author.username}'s Monthly`) | ||
.setDescription(`You have to wait ${days}d ${hours}h ${minutes}m ${seconds}s before you can collect your monthly earnings!`) | ||
] | ||
}) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters