Merge pull request #457 from VermiumSifell/438-bug-credits-gift-value-overflow-when-gifting-more-than-2147483662
438 bug credits gift value overflow when gifting more than 2147483662
This commit is contained in:
commit
f0f690b740
2 changed files with 10 additions and 3 deletions
|
@ -23,6 +23,8 @@ export const builder = (command: SlashCommandSubcommandBuilder) => {
|
||||||
.setName("credits")
|
.setName("credits")
|
||||||
.setDescription("The amount of credits you want to gift.")
|
.setDescription("The amount of credits you want to gift.")
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
|
.setMinValue(1)
|
||||||
|
.setMaxValue(100000000)
|
||||||
)
|
)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option.setName("reason").setDescription("Your reason.")
|
option.setName("reason").setDescription("Your reason.")
|
||||||
|
|
|
@ -57,13 +57,18 @@ export default async (guild: Guild, from: User, to: User, amount: number) => {
|
||||||
throw new Error("You can't transfer below one credit.");
|
throw new Error("You can't transfer below one credit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Verify that recipient are not an bot.
|
// 6. Verify that the sender is not trying to send more than 100.000.000 credits.
|
||||||
|
if (amount > 100000000) {
|
||||||
|
throw new Error("You can't transfer more than 100.000.000 credits.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Verify that recipient are not an bot.
|
||||||
if (to.bot) throw new Error("You can't transfer to an bot.");
|
if (to.bot) throw new Error("You can't transfer to an bot.");
|
||||||
|
|
||||||
// 7. Verify that sender and recipient are not the same user.
|
// 8. Verify that sender and recipient are not the same user.
|
||||||
if (from.id === to.id) throw new Error("You can't transfer to yourself.");
|
if (from.id === to.id) throw new Error("You can't transfer to yourself.");
|
||||||
|
|
||||||
// 8. Increment the recipient's balance by amount.
|
// 9. Increment the recipient's balance by amount.
|
||||||
const recipient = await tx.guildMember.upsert({
|
const recipient = await tx.guildMember.upsert({
|
||||||
update: {
|
update: {
|
||||||
creditsEarned: {
|
creditsEarned: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue