Merge branch 'dev' into 'main'

Updated buttonhandler to ignore tempbuttons

See merge request illegitimate/illegitimate-bot!277
This commit is contained in:
2024-09-09 20:37:07 +00:00
3 changed files with 15 additions and 4 deletions

View File

@@ -35,8 +35,8 @@ export default async function prune(interaction: ChatInputCommandInteraction): P
}
const id = Math.random().toString(32).slice(2)
const buttonid = "button-" + id
const cancelid = "cancel-" + id
const buttonid = `tempbutton-pruneconfirm-${id}`
const cancelid = `tempbutton-prunecancel-${id}`
await interaction.editReply({
embeds: [{

View File

@@ -41,11 +41,19 @@ export default {
}
if (interaction.isButton()) {
const customId = interaction.customId
let btnId: string = ""
if (customId.startsWith("tempbutton-")) {
btnId = customId.split("-")[1]
btnId = btnId.split("-")[0]
}
console.log(
color(
interaction.user.username + "#" +
interaction.user.discriminator + " clicked " +
interaction.customId,
btnId,
"pink"
)
)

View File

@@ -32,7 +32,10 @@ export default async function loadButtonEvents(client: Client, ft: FileType) {
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isButton()) return
const button = client.buttons.get(interaction.customId)
const customId = interaction.customId
if (customId.startsWith("tempbutton-")) return
const button = client.buttons.get(customId)
if (!button) {
console.error(`No event matching ${interaction.customId} was found.`)