From 50f9193349b0d93e0a21d1d80a7796717c31cbfd Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 24 Apr 2024 22:11:55 -0600 Subject: [PATCH] Do thing --- index.js | 27 ++++++++++++--------------- sendInvites.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 sendInvites.js diff --git a/index.js b/index.js index 26244de..13b094f 100644 --- a/index.js +++ b/index.js @@ -292,23 +292,12 @@ client.on("ready", async () => { ] }, { - name: "confirm1", - description: "Confirm the DEFCON level change.", - type: 5, - required: true - }, - { - name: "confirm2", - description: "Are you REALLY sure?", - type: 5, - required: true + name: "reason", + description: "Why is the defcon changing to this level?", + required: true, + type: 3 } ] - }, - { - name: "msg", - description: "Send a message to a channel.", - default_member_permissions: 0 } ] // Do slash command stuff @@ -332,6 +321,8 @@ client.on('interactionCreate', async interaction => { switch (command) { case "defcon": + // Check if reason is set, if not return + if (!interaction.options.getString("reason")) return interaction.reply({ephemeral: true, content: "You MUST provide a reason!"}); // Update defcon let level = interaction.options.getString("level"); newLevel = new Number(level); @@ -350,6 +341,12 @@ client.on('interactionCreate', async interaction => { color, title: `We are now at DEFCON ${defcon}`, description: config.DEFCON.levels[defcon].message, + fields: [ + { + name: "Reason", + value: interaction.options.getString("reason") + } + ], footer: { text: `Updated by ${interaction.user.displayName}` }, diff --git a/sendInvites.js b/sendInvites.js new file mode 100644 index 0000000..86cc3f3 --- /dev/null +++ b/sendInvites.js @@ -0,0 +1,44 @@ +const Discord = require("discord.js"); +const client = new Discord.Client({intents: ["GuildMembers", "DirectMessages"]}); +const config = require("./config.json"); + +//const users = ["289884287765839882"] +const users = ["1100667180217016401", "1189636078920015963", "876951410665742368", "582569065210445834", "812898085856346172"]; +const guildId = "1227352256094011513"; +const channel = "1227353607750418472" +client.on('ready', () => { + console.log("Getting ready to send messages..."); + var server; + client.guilds.fetch(guildId).then((guild) => { + server = guild + }) + users.forEach(userId => { + client.users.fetch(userId).then(user => { + console.log(`Got ${user.displayName}!`); + server.invites.create(channel, { + maxAge: 21600, + maxUses: 1, + reason: "Invitation Approved by Chris", + unique: true + }).then(invite => { + console.log(`Made invite "${invite.code}" for ${user.displayName}`); + user.send({ + embeds: [ + { + color: 0x00ff00, + title: "Important Message from The Stash!", + description: `You've been invited to join a super secret staff-only Discord server, where you can directly talk to, and report users to server staff!\nIt's recommended you join as soon as you can, the invite provided will expire !\n\nIf you have any questions, feel free to DM <@289884287765839882>` + } + ], + content: invite.url + }).then(() => { + console.log(`Successfully sent invite to ${user.displayName}`); + }).catch((err) => { + console.log(`[ERROR] Couldnt send invite code "${invite.code}" to ${user.displayName}!!!!!!!!`); + }); + }) + }) + }); +}); + +client.login(config.discord.token); \ No newline at end of file