DudeThatsErin

setup-suggs.js

Apr 26th, 2021
643
14 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const connection = require('../database.js');
  3. const fs = require('fs');
  4. const { channelIDs } = require('../config.json');
  5.  
  6. function addChannelID(suggID) {
  7.     channelIDs.push(suggID);
  8.  
  9.     let newConfigObj = {
  10.         ...require('../config.json'),
  11.         channelIDs
  12.     };
  13.  
  14.     let newFileString = JSON.stringify(newConfigObj, null, 2);
  15.  
  16.     fs.writeFileSync('./config.json', newFileString);
  17. }
  18.  
  19. module.exports = {
  20.     name: 'setup-suggestions',
  21.     aliases: ['setups', 'setup-suggs', 'setupsuggs', 'setupsuggestion', 'setupsugg', 'setup-sugg'],
  22.     inHelp: 'yes',
  23.     description: 'Sets up the Suggestions system and creates a Suggestions channel amd Discussions channel if there is not one. Stores the channel IDs for the bot to use. You **must** run this first before you can use the Suggestions system.',
  24.     usage: 's.setup-suggs [name of suggestions channel]',
  25.     async execute(message, args) {
  26.  
  27.             message.reply('What name would you like to have for where people submit suggestions?');
  28.             const name = args.join(' ');
  29.             const suggestionsCH = await message.guild.channels.create(name, {
  30.                 type: 'text',
  31.                 reason: 'Sakura Moon needed a suggestions channel for the suggestions handler.',
  32.                 permissionOverwrites: [
  33.                     {
  34.                         id: message.guild.roles.everyone,
  35.                         deny: ['ADD_REACTIONS']
  36.                     }
  37.                 ],
  38.             });
  39.                 const suggID = suggestionsCH.id;
  40.                 if(channelIDs.includes(`${suggID}`)) {
  41.                     message.channel.send('I have created the suggestions channel and stored the ID in my database.');
  42.                 } else {
  43.                     addChannelID(`${suggID}`);
  44.                     message.channel.send('I have created the suggestions channel and stored the ID in my database.');
  45.                 }
  46.  
  47.  
  48.             message.reply('What name would you like to have for where people can discuss suggestions?');
  49.             const nameD = args.join(' ');
  50.             const discussionsCH = await message.guild.channels.create(nameD, {
  51.                 type: 'text',
  52.                 reason: 'Sakura Moon needed a discussions channel for the suggestions handler.'
  53.             });
  54.                 const discID = discussionsCH.id;
  55.                 if(channelIDs.includes(`${discID}`)) {
  56.                     message.channel.send('I have created the discussions channel for the Suggestions System and stored the ID in my database.');
  57.                 } else {
  58.                     addChannelID(`${discID}`);
  59.                     message.channel.send('I have created the suggestions channel and stored the ID in my database.');
  60.                 }
  61.  
  62.     }
  63. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×