mirror of
https://github.com/SrIzan10/vinci.git
synced 2026-06-06 01:07:00 +00:00
feat: change suggestion decision :Pog:
This commit is contained in:
@@ -6,32 +6,45 @@ export default commandModule({
|
||||
type: CommandType.Button,
|
||||
async execute(interaction) {
|
||||
const convertToNumber = Number(interaction.component.label!)
|
||||
const downvotebuttons = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder(interaction.message!.components[0].components[0].data),
|
||||
new ButtonBuilder()
|
||||
.setCustomId('suggestions-no')
|
||||
.setEmoji('❎')
|
||||
.setLabel((convertToNumber + 1).toString())
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
const row2 = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder(interaction.message!.components[1].components[0].data),
|
||||
new ButtonBuilder(interaction.message!.components[1].components[1].data)
|
||||
)
|
||||
await db.exists({msgid: interaction.message.id, userid: interaction.user.id}, async (err, doc) => {
|
||||
if (err) throw err
|
||||
if (doc) {
|
||||
await interaction.reply({content: 'Ya has hecho upvote/downvote, no puedes hacerlo de nuevo.', ephemeral: true})
|
||||
} else {
|
||||
const addToDB = new db({
|
||||
msgid: interaction.message.id,
|
||||
userid: interaction.user.id,
|
||||
upordown: -1
|
||||
})
|
||||
await addToDB.save()
|
||||
await interaction.message.edit({components: [downvotebuttons, row2]})
|
||||
await interaction.deferUpdate()
|
||||
}
|
||||
})
|
||||
if (await db.exists({msgid: interaction.message.id, userid: interaction.user.id, upordown: 1})) {
|
||||
await db.findOneAndUpdate({msgid: interaction.message.id, userid: interaction.user.id, upordown: 1}, {upordown: -1}, {returnOriginal: false})
|
||||
// god forbid I use any! I'm literally done with trying to solve this dude
|
||||
const upvoteLabel = JSON.stringify(interaction.message!.components[0].components[0].data) as string
|
||||
const downvotebuttons = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder(interaction.message!.components[0].components[0].data)
|
||||
.setLabel((Number(JSON.parse(upvoteLabel).label) - 1).toString()),
|
||||
new ButtonBuilder()
|
||||
.setCustomId('suggestions-no')
|
||||
.setEmoji('❎')
|
||||
.setLabel((convertToNumber + 1).toString())
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
await interaction.message.edit({components: [downvotebuttons, row2]})
|
||||
await interaction.deferUpdate()
|
||||
} else if (await db.exists({msgid: interaction.message.id, userid: interaction.user.id, upordown: -1})) {
|
||||
return await interaction.reply({content: 'Ya has hecho downvote.', ephemeral: true})
|
||||
} else {
|
||||
const downvotebuttons = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder(interaction.message!.components[0].components[0].data),
|
||||
new ButtonBuilder()
|
||||
.setCustomId('suggestions-no')
|
||||
.setEmoji('❎')
|
||||
.setLabel((convertToNumber + 1).toString())
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
|
||||
const addToDB = new db({
|
||||
msgid: interaction.message.id,
|
||||
userid: interaction.user.id,
|
||||
upordown: -1
|
||||
})
|
||||
await addToDB.save()
|
||||
await interaction.message.edit({components: [downvotebuttons, row2]})
|
||||
await interaction.deferUpdate()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -6,32 +6,45 @@ export default commandModule({
|
||||
type: CommandType.Button,
|
||||
async execute(interaction) {
|
||||
const convertToNumber = Number(interaction.component.label!)
|
||||
const upvotebuttons = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('suggestions-yes')
|
||||
.setEmoji('✅')
|
||||
.setLabel((convertToNumber + 1).toString())
|
||||
.setStyle(ButtonStyle.Success),
|
||||
new ButtonBuilder(interaction.message!.components[0].components[1].data)
|
||||
)
|
||||
const row2 = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder(interaction.message!.components[1].components[0].data),
|
||||
new ButtonBuilder(interaction.message!.components[1].components[1].data)
|
||||
)
|
||||
await db.exists({msgid: interaction.message.id, userid: interaction.user.id}, async (err, doc) => {
|
||||
if (err) throw err
|
||||
if (doc) {
|
||||
await interaction.reply({content: 'Ya has hecho upvote/downvote, no puedes hacerlo de nuevo.', ephemeral: true})
|
||||
} else {
|
||||
const addToDB = new db({
|
||||
msgid: interaction.message.id,
|
||||
userid: interaction.user.id,
|
||||
upordown: 1
|
||||
})
|
||||
await addToDB.save()
|
||||
await interaction.message.edit({components: [upvotebuttons, row2]})
|
||||
await interaction.deferUpdate()
|
||||
}
|
||||
})
|
||||
if (await db.exists({msgid: interaction.message.id, userid: interaction.user.id, upordown: -1})) {
|
||||
await db.findOneAndUpdate({msgid: interaction.message.id, userid: interaction.user.id, upordown: -1}, {upordown: 1}, {returnOriginal: false})
|
||||
// god forbid I use any! I'm literally done with trying to solve this dude
|
||||
const upvoteLabel = JSON.stringify(interaction.message!.components[0].components[1].data) as string
|
||||
const downvotebuttons = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('suggestions-yes')
|
||||
.setEmoji('✅')
|
||||
.setLabel((convertToNumber + 1).toString())
|
||||
.setStyle(ButtonStyle.Success),
|
||||
new ButtonBuilder(interaction.message!.components[0].components[1].data)
|
||||
.setLabel((Number(JSON.parse(upvoteLabel).label) - 1).toString()),
|
||||
)
|
||||
await interaction.message.edit({components: [downvotebuttons, row2]})
|
||||
await interaction.deferUpdate()
|
||||
} else if (await db.exists({msgid: interaction.message.id, userid: interaction.user.id, upordown: 1})) {
|
||||
return await interaction.reply({content: 'Ya has hecho upvote.', ephemeral: true})
|
||||
} else {
|
||||
const downvotebuttons = new ActionRowBuilder<ButtonBuilder>().setComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('suggestions-yes')
|
||||
.setEmoji('✅')
|
||||
.setLabel((convertToNumber + 1).toString())
|
||||
.setStyle(ButtonStyle.Success),
|
||||
new ButtonBuilder(interaction.message!.components[0].components[1].data)
|
||||
)
|
||||
|
||||
const addToDB = new db({
|
||||
msgid: interaction.message.id,
|
||||
userid: interaction.user.id,
|
||||
upordown: 1
|
||||
})
|
||||
await addToDB.save()
|
||||
await interaction.message.edit({components: [downvotebuttons, row2]})
|
||||
await interaction.deferUpdate()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { commandModule, CommandType } from '@sern/handler'
|
||||
import { publish } from "../../src/plugins/publish.js";
|
||||
import { createAudioPlayer, createAudioResource, joinVoiceChannel } from "@discordjs/voice";
|
||||
import { createAudioPlayer, createAudioResource, DiscordGatewayAdapterCreator, joinVoiceChannel } from "@discordjs/voice";
|
||||
import got from "got";
|
||||
import { ApplicationCommandOptionType, EmbedBuilder } from "discord.js";
|
||||
/*
|
||||
@@ -45,8 +45,8 @@ export default commandModule({
|
||||
.setDescription(`La radio no ha sido encontrada, asegúrate que la radio está escogida de la lista.`);
|
||||
|
||||
async function playRadio(radioname: string) {
|
||||
const stream = await got.stream(radioname)
|
||||
const connection = joinVoiceChannel({adapterCreator: ctx.guild.voiceAdapterCreator,channelId: '1008730592835281009',guildId: '928018226330337280',selfDeaf: true});
|
||||
const stream = got.stream(radioname)
|
||||
const connection = joinVoiceChannel({adapterCreator: ctx.interaction.guild!.voiceAdapterCreator as DiscordGatewayAdapterCreator, channelId: '1008730592835281009',guildId: '928018226330337280',selfDeaf: true});
|
||||
const resource = createAudioResource(stream, { inlineVolume: true });
|
||||
const player = createAudioPlayer();
|
||||
connection.subscribe(player)
|
||||
|
||||
2
index.ts
2
index.ts
@@ -18,6 +18,8 @@ if (process.argv[2] === '--dev') {
|
||||
dotenv()
|
||||
}
|
||||
|
||||
console.clear()
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -34,7 +34,7 @@
|
||||
"@types/express": "^4.17.14",
|
||||
"ts-node": "10.9.1",
|
||||
"tsc-watch": "^5.0.3",
|
||||
"typescript": "4.9.3"
|
||||
"typescript": "^4.9.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@consumet/extensions": {
|
||||
|
||||
@@ -52,6 +52,6 @@
|
||||
"@types/express": "^4.17.14",
|
||||
"ts-node": "10.9.1",
|
||||
"tsc-watch": "^5.0.3",
|
||||
"typescript": "4.9.3"
|
||||
"typescript": "^4.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user