-
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 #33 from RappyLabyAddons/feat/adminActions
Allow admins to perform actions
- Loading branch information
Showing
12 changed files
with
158 additions
and
75 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
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,37 @@ | ||
import { ButtonInteraction, CacheType, Message, GuildMember, User, EmbedBuilder, ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from "discord.js"; | ||
import Button from "../structs/Button"; | ||
import players from "../../database/schemas/players"; | ||
import { validation } from "../../../config.json"; | ||
import { colors } from "../bot"; | ||
|
||
export default class SetTag extends Button { | ||
constructor() { | ||
super("setTag"); | ||
} | ||
|
||
async trigger(interaction: ButtonInteraction<CacheType>, message: Message<boolean>, member: GuildMember, user: User) { | ||
const player = await players.findOne({ uuid: message.embeds[0].fields[0].value.replaceAll(`\``, ``) }); | ||
if(!player) return interaction.reply({ embeds: [new EmbedBuilder().setColor(colors.error).setDescription(`❌ Player not found!`)], ephemeral: true }); | ||
|
||
const input = new TextInputBuilder() | ||
.setLabel(`New tag`) | ||
.setCustomId(`tag`) | ||
.setPlaceholder(`Enter a tag`) | ||
.setRequired(true) | ||
.setMinLength(validation.tag.min) | ||
.setMaxLength(validation.tag.max) | ||
.setStyle(TextInputStyle.Short); | ||
|
||
if(player.tag) input.setValue(player.tag); | ||
|
||
const modal = new ModalBuilder() | ||
.setTitle(`Set new tag`) | ||
.setCustomId(`setTag`) | ||
.addComponents( | ||
new ActionRowBuilder<TextInputBuilder>() | ||
.addComponents(input) | ||
) | ||
|
||
interaction.showModal(modal); | ||
} | ||
} |
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,20 @@ | ||
import { CacheType, Message, GuildMember, User, EmbedBuilder, ModalSubmitInteraction, ModalSubmitFields } from "discord.js"; | ||
import players from "../../database/schemas/players"; | ||
import { colors } from "../bot"; | ||
import Modal from "../structs/Modal"; | ||
|
||
export default class SetTag extends Modal { | ||
constructor() { | ||
super("setTag"); | ||
} | ||
|
||
async submit(interaction: ModalSubmitInteraction<CacheType>, message: Message<boolean>, fields: ModalSubmitFields, member: GuildMember, user: User) { | ||
const player = await players.findOne({ uuid: message.embeds[0].fields[0].value.replaceAll(`\``, ``) }); | ||
if(!player) return interaction.reply({ embeds: [new EmbedBuilder().setColor(colors.error).setDescription(`❌ Player not found!`)], ephemeral: true }); | ||
|
||
player.tag = fields.getTextInputValue('tag'); | ||
player.save(); | ||
|
||
interaction.reply({ embeds: [new EmbedBuilder().setColor(colors.success).setDescription(`✅ The tag was successfully set!`)], ephemeral: true }); | ||
} | ||
} |
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
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
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
Oops, something went wrong.