-
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.
Merge pull request #26 from N3aar/feat/exp-adjustments
feat: set level command and exp adjustments
- Loading branch information
Showing
4 changed files
with
72 additions
and
7 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,59 @@ | ||
import { adminPermission } from "@/utils/contants.js"; | ||
import { Command } from "@sapphire/framework"; | ||
|
||
export class SetLevelCommand extends Command { | ||
public constructor(context: Command.LoaderContext, options: Command.Options) { | ||
super(context, { ...options }); | ||
} | ||
|
||
public override registerApplicationCommands(registry: Command.Registry) { | ||
registry.registerChatInputCommand((builder) => | ||
builder | ||
.setName("setlevel") | ||
.setDescription("Definir o level de outro usuário") | ||
.setDefaultMemberPermissions(adminPermission) | ||
.addUserOption((option) => { | ||
option.setName("usuario"); | ||
option.setDescription("Usuário que receberá o nível"); | ||
option.setRequired(true); | ||
return option; | ||
}) | ||
.addNumberOption((option) => { | ||
option.setName("level"); | ||
option.setDescription("Nivel que o usuário irá receber"); | ||
option.setMinValue(1); | ||
option.setRequired(true); | ||
return option; | ||
}), | ||
); | ||
} | ||
|
||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { | ||
const user = interaction.options.getUser("usuario"); | ||
const level = interaction.options.getNumber("level"); | ||
|
||
if (!user || !level) return; | ||
|
||
await this.container.db.user.upsert({ | ||
where: { | ||
discordId: user.id, | ||
}, | ||
update: { | ||
level, | ||
xp: 0, | ||
}, | ||
create: { | ||
discordId: user.id, | ||
level, | ||
}, | ||
}); | ||
|
||
this.container.expHandler.deleteMemberFromCache(user.id); | ||
|
||
await interaction.reply({ | ||
content: "Nivel do usuário definido com sucesso!", | ||
ephemeral: true, | ||
fetchReply: false, | ||
}); | ||
} | ||
} |
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