mirror of
https://github.com/SrIzan10/femboybot.git
synced 2026-06-06 00:56:50 +00:00
feat: finally awards command
This commit is contained in:
42
.vscode/awards.code-snippets
vendored
Normal file
42
.vscode/awards.code-snippets
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
// Place your femboybot workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
||||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
||||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||
// Placeholders with the same ids are connected.
|
||||
// Example:
|
||||
// "Print to console": {
|
||||
// "scope": "javascript,typescript",
|
||||
// "prefix": "log",
|
||||
// "body": [
|
||||
// "console.log('$1');",
|
||||
// "$2"
|
||||
// ],
|
||||
// "description": "Log output to console"
|
||||
// }
|
||||
"Awards: Create input": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "in",
|
||||
"body": [
|
||||
"const input$1 = new TextInputBuilder()\r\n\t.setCustomId('$2')\r\n\t.setLabel('$3')\r\n\t.setStyle(TextInputStyle.Short);"
|
||||
],
|
||||
"description": "Create input"
|
||||
},
|
||||
"Awards: ActionRowBuilder": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "ac",
|
||||
"body": [
|
||||
"const $1 =\r\n\tnew ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(\r\n\t\tinput$2\r\n\t);"
|
||||
],
|
||||
"description": "Create ActionRowBuilder"
|
||||
},
|
||||
"Awards: Response": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "res",
|
||||
"body": [
|
||||
"const resp$1 = ctx.fields.getTextInputValue('$2')"
|
||||
],
|
||||
"description": "ye"
|
||||
}
|
||||
}
|
||||
102
commands/handler/awards-1.ts
Normal file
102
commands/handler/awards-1.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import { commandModule, CommandType } from '@sern/handler';
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder, ModalActionRowComponentBuilder, ModalBuilder, TextChannel, TextInputBuilder, TextInputStyle } from 'discord.js';
|
||||
|
||||
export default commandModule({
|
||||
type: CommandType.Modal,
|
||||
plugins: [],
|
||||
execute: async (ctx) => {
|
||||
await ctx.deferReply({ephemeral: true})
|
||||
const resp1 = ctx.fields.getTextInputValue('clip-del-ano')
|
||||
const resp2 = ctx.fields.getTextInputValue('video-del-ano')
|
||||
const resp3 = ctx.fields.getTextInputValue('integrante-racista')
|
||||
const resp4 = ctx.fields.getTextInputValue('bot-mas-importante')
|
||||
const resp5 = ctx.fields.getTextInputValue('mejor-mc-server')
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor('Green')
|
||||
.setAuthor({
|
||||
name: ctx.user.username,
|
||||
iconURL: ctx.user.displayAvatarURL()
|
||||
})
|
||||
.setTitle('Awards response')
|
||||
.setFields(
|
||||
{ name: 'Clip del año', value: resp1 },
|
||||
{ name: 'Vídeo del año', value: resp2 },
|
||||
{ name: 'Integrante más racista', value: resp3 },
|
||||
{ name: 'Bot más importante', value: resp4 },
|
||||
{ name: 'Mejor server de MC jugado', value: resp5 },
|
||||
);
|
||||
const fetchChannel = await ctx.client.channels.fetch(process.env.AWARDS!) as TextChannel
|
||||
const message = await fetchChannel.send({
|
||||
embeds: [embed]
|
||||
})
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId('awards-2')
|
||||
.setTitle('Awards (parte 2)');
|
||||
const input = new TextInputBuilder()
|
||||
.setCustomId('mas-horas-llamada')
|
||||
.setLabel('Integrante con más horas en llamada')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input2 = new TextInputBuilder()
|
||||
.setCustomId('mas-mensajes-enviados')
|
||||
.setLabel('Integrante con más mensajes enviados')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input3 = new TextInputBuilder()
|
||||
.setCustomId('mejor-emote')
|
||||
.setLabel('Mejor emote')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input4 = new TextInputBuilder()
|
||||
.setCustomId('integrante-degenerado')
|
||||
.setLabel('Integrante más degenerado')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input5 = new TextInputBuilder()
|
||||
.setCustomId('juego-mas-jugado')
|
||||
.setLabel('Juego más jugado')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const one =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input
|
||||
);
|
||||
const two =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input2
|
||||
);
|
||||
const three =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input3
|
||||
);
|
||||
const four =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input4
|
||||
);
|
||||
const five =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input5
|
||||
);
|
||||
modal.addComponents([one, two, three, four, five]);
|
||||
|
||||
const userEmbed = new EmbedBuilder()
|
||||
.setColor('Green')
|
||||
.setTitle('Aún no se ha acabado!')
|
||||
.setDescription('Continúa dándole al botón!\nEn el embed de más abajo podrás ver tus respuestas hechas de momento.')
|
||||
.setFooter({ text: `ID: ${message.id}` })
|
||||
const userButton = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('awards-continue-1')
|
||||
.setLabel('Continuar')
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
const userMsg = await ctx.editReply({
|
||||
embeds: [userEmbed, embed],
|
||||
components: [userButton]
|
||||
})
|
||||
const collector = userMsg.createMessageComponentCollector({ time: 60_000, componentType: ComponentType.Button, max: 1 })
|
||||
collector.on('collect', async (i) => {
|
||||
if (i.customId !== 'awards-continue-1') return;
|
||||
|
||||
await i.showModal(modal)
|
||||
})
|
||||
},
|
||||
});
|
||||
83
commands/handler/awards-2.ts
Normal file
83
commands/handler/awards-2.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { commandModule, CommandType } from '@sern/handler';
|
||||
import { ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalActionRowComponentBuilder, EmbedBuilder, TextChannel, ButtonBuilder, ButtonStyle, ComponentType } from 'discord.js';
|
||||
|
||||
export default commandModule({
|
||||
type: CommandType.Modal,
|
||||
plugins: [],
|
||||
execute: async (ctx) => {
|
||||
await ctx.deferReply({ephemeral: true})
|
||||
const resp1 = ctx.fields.getTextInputValue('mas-horas-llamada')
|
||||
const resp2 = ctx.fields.getTextInputValue('mas-mensajes-enviados')
|
||||
const resp3 = ctx.fields.getTextInputValue('mejor-emote')
|
||||
const resp4 = ctx.fields.getTextInputValue('integrante-degenerado')
|
||||
const resp5 = ctx.fields.getTextInputValue('juego-mas-jugado')
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId('awards-3')
|
||||
.setTitle('Awards (parte 3)');
|
||||
const input = new TextInputBuilder()
|
||||
.setCustomId('mejor-respuesta')
|
||||
.setLabel('Premio a la mejor respuesta')
|
||||
.setPlaceholder('What\'s bofa? BOFA DEEZ NUTS HAHAHAHAAAA')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input2 = new TextInputBuilder()
|
||||
.setCustomId('mejor-mascota')
|
||||
.setLabel('Mejor mascota del servidor')
|
||||
.setPlaceholder('Creo que el olivas se refería a un animal')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input3 = new TextInputBuilder()
|
||||
.setCustomId('opinnion')
|
||||
.setLabel('Algo que quieras que añada al server?')
|
||||
.setPlaceholder('Escribe, no te cortes! :DIESOFCRINGE:')
|
||||
.setStyle(TextInputStyle.Paragraph);
|
||||
const one =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input
|
||||
);
|
||||
const two =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input2
|
||||
);
|
||||
const three =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input3
|
||||
);
|
||||
modal.addComponents([one, two, three]);
|
||||
|
||||
const embed = new EmbedBuilder(ctx.message!.embeds[1].data)
|
||||
.addFields(
|
||||
{ name: 'Integrante con más horas en llamada', value: resp1 },
|
||||
{ name: 'Integrante con más mensajes enviados', value: resp2 },
|
||||
{ name: 'Mejor emote', value: resp3 },
|
||||
{ name: 'Integrante más degenerado', value: resp4 },
|
||||
{ name: 'Juego más jugado', value: resp5 },
|
||||
)
|
||||
const fetchMsg = await (await ctx.client.channels.fetch(process.env.AWARDS!) as TextChannel).messages.fetch(ctx.message!.embeds[0].footer!.text.replace('ID: ', ''))
|
||||
const responseMsg = await fetchMsg.edit({
|
||||
embeds: [embed]
|
||||
})
|
||||
|
||||
const userEmbed = new EmbedBuilder()
|
||||
.setColor('Random')
|
||||
.setTitle('Ya casi estás!')
|
||||
.setDescription('Continúa dándole al botón!\nEn el embed de más abajo podrás ver tus respuestas hechas de hasta ahora.')
|
||||
.setFooter({ text: `ID: ${responseMsg.id}` })
|
||||
const userButton = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('awards-continue-2')
|
||||
.setLabel('Continuar')
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
const userMsg = await ctx.editReply({
|
||||
embeds: [userEmbed, embed],
|
||||
components: [userButton]
|
||||
})
|
||||
const collector = userMsg.createMessageComponentCollector({ time: 60_000, componentType: ComponentType.Button, max: 1 })
|
||||
collector.on('collect', async (i) => {
|
||||
if (i.customId !== 'awards-continue-2') return;
|
||||
|
||||
await i.showModal(modal)
|
||||
})
|
||||
},
|
||||
});
|
||||
51
commands/handler/awards-3.ts
Normal file
51
commands/handler/awards-3.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { commandModule, CommandType } from '@sern/handler';
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, EmbedBuilder, GuildMemberRoleManager, TextChannel } from 'discord.js';
|
||||
|
||||
export default commandModule({
|
||||
type: CommandType.Modal,
|
||||
plugins: [],
|
||||
execute: async (ctx) => {
|
||||
await ctx.deferReply({ephemeral: true})
|
||||
const resp1 = ctx.fields.getTextInputValue('mejor-respuesta')
|
||||
const resp2 = ctx.fields.getTextInputValue('mejor-mascota')
|
||||
const resp3 = ctx.fields.getTextInputValue('opinnion')
|
||||
|
||||
const embed = new EmbedBuilder(ctx.message!.embeds[1].data)
|
||||
.addFields(
|
||||
{ name: 'Mejor respuesta', value: resp1 },
|
||||
{ name: 'Mejor mascota', value: resp2 },
|
||||
{ name: 'Opinión', value: resp3 }
|
||||
)
|
||||
const fetchMsg = await (await ctx.client.channels.fetch(process.env.AWARDS!) as TextChannel).messages.fetch(ctx.message!.embeds[0].footer!.text.replace('ID: ', ''))
|
||||
await fetchMsg.edit({
|
||||
embeds: [embed]
|
||||
})
|
||||
|
||||
const userEmbed = new EmbedBuilder()
|
||||
.setColor('Random')
|
||||
.setTitle('Listo!')
|
||||
.setDescription('Se acabó! Gracias por responder. Las preguntas han sido hechas por <@630502288154427414>.\nEn el embed de más abajo podrás ver tus respuestas hechas.')
|
||||
const userButton = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('awards-responses')
|
||||
.setLabel('Enseñar respuestas finales')
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
)
|
||||
const msg = await ctx.editReply({
|
||||
embeds: [userEmbed],
|
||||
components: [userButton]
|
||||
})
|
||||
const collector = msg.createMessageComponentCollector({componentType: ComponentType.Button, time: 60_000})
|
||||
collector.on('collect', async (i) => {
|
||||
if (i.customId !== 'awards-responses') return;
|
||||
|
||||
await i.deferReply({ ephemeral: true })
|
||||
await i.editReply({
|
||||
embeds: [embed]
|
||||
})
|
||||
})
|
||||
|
||||
await (ctx.member?.roles as GuildMemberRoleManager).add('1060314978273472602')
|
||||
},
|
||||
});
|
||||
100
commands/misc/awards.ts
Normal file
100
commands/misc/awards.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { commandModule, CommandType } from "@sern/handler";
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
ComponentType,
|
||||
GuildMember,
|
||||
ModalActionRowComponentBuilder,
|
||||
ModalBuilder,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js";
|
||||
import { publish } from "../../plugins/publish.js";
|
||||
|
||||
export default commandModule({
|
||||
type: CommandType.Both,
|
||||
plugins: [publish()],
|
||||
description: "pepega!",
|
||||
|
||||
execute: async (ctx, args) => {
|
||||
const fetchUser = (await ctx.guild!.members.fetch(
|
||||
ctx.user.id
|
||||
)) as GuildMember;
|
||||
if (fetchUser.roles.cache.has("1060314978273472602")) {
|
||||
return ctx.reply("No puedes votar de nuevo.");
|
||||
}
|
||||
if (!fetchUser.roles.cache.has("939452789434744872")) {
|
||||
return ctx.reply("No eres del grupo :skull:");
|
||||
}
|
||||
|
||||
const start = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("awards-send")
|
||||
.setLabel("Empezar")
|
||||
.setStyle(ButtonStyle.Success)
|
||||
);
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId('awards-1')
|
||||
.setTitle('Awards (parte 1)');
|
||||
const input = new TextInputBuilder()
|
||||
.setCustomId('clip-del-ano')
|
||||
.setLabel('Clip del año')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input2 = new TextInputBuilder()
|
||||
.setCustomId('video-del-ano')
|
||||
.setLabel('Vídeo del año')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input3 = new TextInputBuilder()
|
||||
.setCustomId('integrante-racista')
|
||||
.setLabel('Integrante más racista')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input4 = new TextInputBuilder()
|
||||
.setCustomId('bot-mas-importante')
|
||||
.setLabel('Bot más importante')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const input5 = new TextInputBuilder()
|
||||
.setCustomId('mejor-mc-server')
|
||||
.setLabel('Mejor servidor de MC jugado')
|
||||
.setStyle(TextInputStyle.Short);
|
||||
const one =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input
|
||||
);
|
||||
const two =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input2
|
||||
);
|
||||
const three =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input3
|
||||
);
|
||||
const four =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input4
|
||||
);
|
||||
const five =
|
||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
||||
input5
|
||||
);
|
||||
modal.addComponents([one, two, three, four, five]);
|
||||
|
||||
const message = await ctx.reply({
|
||||
content: `Bienvenido ${ctx.user}! Empieza haciendo click en el botón!\nTOMATELO EN SERIO PORFIII`,
|
||||
components: [start],
|
||||
})
|
||||
const collector = message.createMessageComponentCollector({componentType: ComponentType.Button, filter: i => i.user.id === ctx.user.id, time: 15_000})
|
||||
collector.on('collect', async (i) => {
|
||||
if (i.customId !== 'awards-send') return;
|
||||
|
||||
await i.showModal(modal)
|
||||
})
|
||||
collector.on('ignore', async (i) => {
|
||||
i.reply({
|
||||
content: 'El botón no es para tí backstaber!',
|
||||
ephemeral: true,
|
||||
})
|
||||
})
|
||||
},
|
||||
});
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^2.0.0",
|
||||
"@sern/handler": "^2.1.1",
|
||||
"axios": "^0.27.2",
|
||||
"discord.js": "^14.2.0",
|
||||
"dotenv": "^16.0.3",
|
||||
@@ -1137,9 +1137,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sern/handler": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-2.0.0.tgz",
|
||||
"integrity": "sha512-i9BbUxwOYX1rn1FUfVFT+c8ltAloEfIMUznOt2T4h1xbWyXm/aKocmcgt5DkBHRU8yGoCfDiFF3E3I1mHln3UQ==",
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-2.1.1.tgz",
|
||||
"integrity": "sha512-yPWOgUvi+9et6fC2BxLyIes5zvOLgorXdpLmI84cN7K7NVpYA/kRj2Y0aqriYb2fOdlPeakptODJwabwDSBfZw==",
|
||||
"dependencies": {
|
||||
"iti": "^0.5.0",
|
||||
"rxjs": "^7.5.6",
|
||||
@@ -2985,9 +2985,9 @@
|
||||
"integrity": "sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ=="
|
||||
},
|
||||
"@sern/handler": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-2.0.0.tgz",
|
||||
"integrity": "sha512-i9BbUxwOYX1rn1FUfVFT+c8ltAloEfIMUznOt2T4h1xbWyXm/aKocmcgt5DkBHRU8yGoCfDiFF3E3I1mHln3UQ==",
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-2.1.1.tgz",
|
||||
"integrity": "sha512-yPWOgUvi+9et6fC2BxLyIes5zvOLgorXdpLmI84cN7K7NVpYA/kRj2Y0aqriYb2fOdlPeakptODJwabwDSBfZw==",
|
||||
"requires": {
|
||||
"iti": "^0.5.0",
|
||||
"rxjs": "^7.5.6",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
],
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^2.0.0",
|
||||
"@sern/handler": "^2.1.1",
|
||||
"axios": "^0.27.2",
|
||||
"discord.js": "^14.2.0",
|
||||
"dotenv": "^16.0.3",
|
||||
|
||||
Reference in New Issue
Block a user