From d41e91c8e4176b0ff608646bf09da5fc41951ad4 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Tue, 18 May 2021 18:39:46 -0500 Subject: [PATCH] Update join message and set slash commands on guild join --- bot/awesomescibo.js | 155 ++++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/bot/awesomescibo.js b/bot/awesomescibo.js index f887c7c..c7fd53e 100755 --- a/bot/awesomescibo.js +++ b/bot/awesomescibo.js @@ -16,82 +16,84 @@ const gitlog = require("gitlog").default; const helpMessage = "`do be helping`: display this help message\n`do be roundgen`: send a pdf round to the channel\n`do be scoring`: start a scoring session\n > `do be scoring (a/b)(4/10)`: add points to Team A or Team B\n > `do be scoring stop`: end scoring session and post final points\n > `do be servers`: send the number of servers this bot is a part of\n > `do be iss`: show the current location of the International Space Station\n`do be training`: send a quick practice problem (you **must** react to your answer, or the bot will yell at you)\n > subject options: astro, phys, chem, math, bio, ess, energy\n`do be top`: list cross-server top 10 players\n `do be about`: List people who contributed to this bot\n Source Code: https://github.com/ADawesomeguy/AwesomeSciBo (don't forget to star!)"; +const slashCommands = [ + { + "name": "train", + "description": "Sends a single training question to be answered", + "options": [ + { + "type": 3, + "name": "subject", + "description": "Optional subject to be used as a filter", + "default": false, + "required": false + } + ] + }, + { + "name": "help", + "description": "Replies with a help message explaining what the bot can do" + }, + { + "name": "rounds", + "options": [ + { + "type": 1, + "name": "generate", + "description": "Generates a round with randomized questions from https://scibowldb.com/", + "options": [] + }, + { + "type": 1, + "name": "list", + "description": "Lists your 5 most recently generated rounds with links", + "options": [] + }, + { + "type": 1, + "name": "hit", + "description": "Shows the total number of rounds hit as well as the number for the specific user", + "options": [] + } + ], + "description": "Commands regarding rounds generated by AwesomeSciBo" + }, + { + "name": "top", + "description": "Lists top ten scores across servers (server specific leaderboard WIP)" + }, + { + "name": "about", + "options": [ + { + "type": 1, + "name": "contributors", + "description": "Lists contributors to the AwesomeSciBo bot", + "options": [] + }, + { + "type": 1, + "name": "changelog", + "description": "Lists the 5 most recent changes in a \"git log\" type format", + "options": [] + }, + { + "type": 1, + "name": "bot", + "description": "Lists information about AwesomeSciBo", + "options": [] + } + ], + "description": "Commands regarding the creation/development of the bot" + }, + { + "name": "iss", + "description": "Shows the location of the ISS on a map as well as all of the current astronauts within it" + } +] + client.once("ready", () => { - client.application.commands.set([ - { - "name": "train", - "description": "Sends a single training question to be answered", - "options": [ - { - "type": 3, - "name": "subject", - "description": "Optional subject to be used as a filter", - "default": false, - "required": false - } - ] - }, - { - "name": "help", - "description": "Replies with a help message explaining what the bot can do" - }, - { - "name": "rounds", - "options": [ - { - "type": 1, - "name": "generate", - "description": "Generates a round with randomized questions from https://scibowldb.com/", - "options": [] - }, - { - "type": 1, - "name": "list", - "description": "Lists your 5 most recently generated rounds with links", - "options": [] - }, - { - "type": 1, - "name": "hit", - "description": "Shows the total number of rounds hit as well as the number for the specific user", - "options": [] - } - ], - "description": "Commands regarding rounds generated by AwesomeSciBo" - }, - { - "name": "top", - "description": "Lists top ten scores across servers (server specific leaderboard WIP)" - }, - { - "name": "about", - "options": [ - { - "type": 1, - "name": "contributors", - "description": "Lists contributors to the AwesomeSciBo bot", - "options": [] - }, - { - "type": 1, - "name": "changelog", - "description": "Lists the 5 most recent changes in a \"git log\" type format", - "options": [] - }, - { - "type": 1, - "name": "bot", - "description": "Lists information about AwesomeSciBo", - "options": [] - } - ], - "description": "Commands regarding the creation/development of the bot" - }, - { - "name": "iss", - "description": "Shows the location of the ISS on a map as well as all of the current astronauts within it" - } - ]); + client.application.commands.set(slashCommands); // Connect to MongoDB using mongoose if (!process.env.CI) { @@ -113,6 +115,7 @@ client.once("ready", () => { }); client.on("guildCreate", (guild) => { + guild.commands.set(slashCommands); const welcomeChannel = guild.channels.cache .find( (channel) => @@ -120,7 +123,7 @@ client.on("guildCreate", (guild) => { channel.name === "general" && channel.type === "text" ) if (welcomeChannel) { - welcomeChannel.send("'Sup, I'm the AwesomeSciBo bot!") + welcomeChannel.send("'Sup, I'm the AwesomeSciBo bot! Use `/help` to learn more about me!"); .catch(console.error); } });