const { Client, Partials, GatewayIntentBits, EmbedBuilder, PermissionsBitField, Permissions, MessageManager, Embed, Collection, Events, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ChannelSelectMenuBuilder, InteractionType } = require(`discord.js`); const client = new Client({ allowedMentions: { parse: [ 'users', 'roles' ], repliedUser: true }, autoReconnect: true, disabledEvents: [ "TYPING_START" ], partials: [ Partials.Channel, Partials.GuildMember, Partials.Message, Partials.Reaction, Partials.User, Partials.GuildScheduledEvent ], intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildBans, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.MessageContent ], restTimeOffset: 0 }); const fs = require('fs'); const theme = require('./embed.json'); client.commands = new Collection(); require('dotenv').config(); const functions = fs.readdirSync("./src/functions").filter(file => file.endsWith(".js")); const eventFiles = fs.readdirSync("./src/events").filter(file => file.endsWith(".js")); const commandFolders = fs.readdirSync("./src/commands"); (async () => { for (file of functions) { require(`./functions/${file}`)(client); } client.handleEvents(eventFiles, "./src/events"); client.handleCommands(commandFolders, "./src/commands"); client.login(process.env.DISCORD_TOKEN) })(); // Modal Suggestion client.on('interactionCreate', async (interaction) => { if (interaction.type === InteractionType.ModalSubmit) { if (interaction.customId === 'modal') { const title = interaction.fields.getTextInputValue('title'); const description = interaction.fields.getTextInputValue('description'); const embed = new EmbedBuilder() .setColor(theme.default) .setAuthor({ name: interaction.user.username, iconURL: interaction.user.avatarURL() }) .setTitle(title) .setDescription(description) .setTimestamp(); const upvoteButton = new ButtonBuilder() .setCustomId('upvote') .setStyle(ButtonStyle.Secondary) .setLabel('⬆️'); const downvoteButton = new ButtonBuilder() .setCustomId('downvote') .setStyle(ButtonStyle.Secondary) .setLabel('⬇️'); const suggestionsChannel = client.channels.cache.get('1200532363889881203'); if (!suggestionsChannel) { console.error('Suggestions channel not found!'); await interaction.reply({ content: 'An error occurred. Please try again later.', ephemeral: true }); return; } if (!suggestionsChannel.permissionsFor(client.user).has('SEND_MESSAGES')) { console.error('Bot lacks permission to send messages in suggestions channel!'); await interaction.reply({ content: 'The bot does not have permission to send messages in the suggestions channel.', ephemeral: true }); return; } suggestionsChannel.send({ embeds: [embed], components: [new ActionRowBuilder().addComponents(upvoteButton, downvoteButton)] }); await interaction.reply({ content: `Your suggestion has been submitted successfully!`, ephemeral: true }); } } });