From d3f2085813ae1ad178a4580d44db37c7990dc4b8 Mon Sep 17 00:00:00 2001 From: ION606 Date: Tue, 13 Sep 2022 10:57:53 -0400 Subject: [PATCH] Fixed the 'setup announcement_role' command and added the 'twitchnotifs.js' file --- commands/admin/setup.js | 141 ++++++++++++++++--------------- commands/premium/twitchnotifs.js | 4 + 2 files changed, 78 insertions(+), 67 deletions(-) create mode 100644 commands/premium/twitchnotifs.js diff --git a/commands/admin/setup.js b/commands/admin/setup.js index 518154a..c16a42c 100644 --- a/commands/admin/setup.js +++ b/commands/admin/setup.js @@ -27,79 +27,86 @@ async function execute(bot, message, args, command, Discord, mongouri, items, xp bot.mongoconnection.then(async (client) => { // if (err) { return console.log(err); } - //Initialize - CreateNewCollection(message, client, server, owner.user.id); + try { + //Initialize + CreateNewCollection(message, client, server, owner.user.id); - const db = client.db(server); - const dbo = db.collection('SETUP'); + const db = client.db(server); + const dbo = db.collection('SETUP'); - //Chose the appropriate command - command = args[0]; + //Chose the appropriate command + command = args[0]; - if (!command) { - message.channel.send('Please use the following format _!setup help _'); - } else if (command == 'welcome_channel') { - if (args.length != 2) { return message.reply('The command format is _!setup welcome_channel _'); } - // setWelcomeChannel(dbo, message, args[1]); - const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); - if (!channel) { return message.reply('The specified channel does not exist!'); } + if (!command) { + message.channel.send('Please use the following format _!setup help _'); + } else if (command == 'welcome_channel') { + if (args.length != 2) { return message.reply('The command format is _!setup welcome_channel _'); } + // setWelcomeChannel(dbo, message, args[1]); + const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); + if (!channel) { return message.reply('The specified channel does not exist!'); } - dbo.updateOne({welcomechannel: {$exists: true}}, {$set: {welcomechannel: `${channel.id}`}}); - message.reply(`Set ${channel} as the new welcome channel`) - } else if (command == 'welcome_message') { - if (args.length < 2) { return message.reply('The command format is _!setup welcome\\_message_\nUse _{sn}_ to insert the server name, _{un}_ to insert the user name, and _{ut}_ to insert the user tag\nExample: _!setup welcome\\_message Welcome to {sn} Sir {un}#{ut}_'); } - let msg = ""; - for (let i = 1; i < args.length; i ++ ) { - msg += args[i] + ' '; + dbo.updateOne({welcomechannel: {$exists: true}}, {$set: {welcomechannel: `${channel.id}`}}); + message.reply(`Set ${channel} as the new welcome channel`) + } else if (command == 'welcome_message') { + if (args.length < 2) { return message.reply('The command format is _!setup welcome\\_message_\nUse _{sn}_ to insert the server name, _{un}_ to insert the user name, and _{ut}_ to insert the user tag\nExample: _!setup welcome\\_message Welcome to {sn} Sir {un}#{ut}_'); } + let msg = ""; + for (let i = 1; i < args.length; i ++ ) { + msg += args[i] + ' '; + } + + if (msg.length > 30) { return message.reply('Please specify a welcome message under 30 characters!'); } + dbo.updateOne({welcomemessage: {$exists: true}}, {$set: {welcomemessage: msg}}) + } else if (command == 'keep_logs') { + if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup keep\\_logs true'); } + + let keeplogs = false; + if (args[1] == 'true') { keeplogs = true; } + + dbo.updateOne({ _id: 'LOG'}, {$set: {keepLogs: keeplogs}}); + + message.reply(`Toggled log keeping to ${keeplogs}. Please use _!setup log_channel_ to choose the log channel`); + } else if (command == 'log_channel') { + if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup log\\_channel true_'); } + + const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); + if (!channel) { return message.reply('The specified channel does not exist!'); } + + dbo.updateOne({_id: 'LOG'}, {$set: {logchannel: `${channel.id}`}}); + message.reply(`Made ${channel} the new Selmer Bot Logs channel!`); + } else if (command == 'log_severity') { + const tier = args[1]; + const l = ['none', 'low', 'medium', 'high']; + if (!l.includes(tier)) { return message.reply("Please select an existing tier ('none', 'low', 'medium', 'high')"); } + + dbo.updateOne({_id: 'LOG'}, {$set: {severity: tier}}) + } else if (command == 'announcement_role') { + if (message.mentions.roles.first() == undefined) { + return message.reply("Please mention a role (_!setup announcement\\_role **@role**_)\n_Note: Selmer Bot does NOT ping the @everyone role_"); + } + const role = message.mentions.roles.first().id; + dbo.updateOne({_id: 'announcement'}, { $set: { 'role': role } }); + } else if (command == "announcement_channel") { + const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); + if (!channel) { return message.reply('The specified channel does not exist!'); } + dbo.updateOne({_id: 'announcement'}, { $set: { 'channel': channel } }); } + + else if (command == 'help') { + let temp; + if (args[1] == 'welcome') { + temp = 'Use _!setup welcome\\_channel [channel name]_ to set the welcome channel and _!setup welcome\\_message [message]_ to set a welcome message!\n'; + } else if (args[1] == 'logs') { + temp = 'To enable logging, use the command _!setup keep\\_logs true_ and _!setup log\\_channel_ [channel name] to set the logging channel!\n'; + temp += 'Use _!setup keep\\_logs false_ to disable logging and _!setup log\\_severity [none, low, medium, high]_ to set the threshold\n'; + temp += '__Severities:__\n*none* - unmute, unban\n*low* - mute\n*medium* - kick\n*high* - ban\nEvery tier also includes all notifs for ***higher*** tiers (AKA _!setup log\\_severity none_ will log everything from every severity)\n'; + } else if (args[1] == 'announcement') { + temp = "To pick the announcement channel, use _!setup announcement\\_channel_\nTo pick the announcement role, use _!setup announcement\\_role_"; + } else { temp = 'Use _!setup Please use the following format: _!setup help [welcome, logs, announcement]_\nExample: _!setup help welcome_'; } - if (msg.length > 30) { return message.reply('Please specify a welcome message under 30 characters!'); } - dbo.updateOne({welcomemessage: {$exists: true}}, {$set: {welcomemessage: msg}}) - } else if (command == 'keep_logs') { - if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup keep\\_logs true'); } - - let keeplogs = false; - if (args[1] == 'true') { keeplogs = true; } - - dbo.updateOne({ _id: 'LOG'}, {$set: {keepLogs: keeplogs}}); - - message.reply(`Toggled log keeping to ${keeplogs}. Please use _!setup log_channel_ to choose the log channel`); - } else if (command == 'log_channel') { - if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup log\\_channel true_'); } - - const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); - if (!channel) { return message.reply('The specified channel does not exist!'); } - - dbo.updateOne({_id: 'LOG'}, {$set: {logchannel: `${channel.id}`}}); - message.reply(`Made ${channel} the new Selmer Bot Logs channel!`); - } else if (command == 'log_severity') { - const tier = args[1]; - const l = ['none', 'low', 'medium', 'high']; - if (!l.includes(tier)) { return message.reply("Please select an existing tier ('none', 'low', 'medium', 'high')"); } - - dbo.updateOne({_id: 'LOG'}, {$set: {severity: tier}}) - } else if (command == 'announcement_role') { - const role = message.mentions.roles.first().id; - dbo.updateOne({_id: 'announcement'}, { $set: { 'role': role } }); - } else if (command == "announcement_channel") { - const channel = message.guild.channels.cache.find(ch => ch.name === args[1]); - if (!channel) { return message.reply('The specified channel does not exist!'); } - dbo.updateOne({_id: 'announcement'}, { $set: { 'channel': channel } }); - } - - else if (command == 'help') { - let temp; - if (args[1] == 'welcome') { - temp = 'Use _!setup welcome\\_channel [channel name]_ to set the welcome channel and _!setup welcome\\_message [message]_ to set a welcome message!\n'; - } else if (args[1] == 'logs') { - temp = 'To enable logging, use the command _!setup keep\\_logs true_ and _!setup log\\_channel_ [channel name] to set the logging channel!\n'; - temp += 'Use _!setup keep\\_logs false_ to disable logging and _!setup log\\_severity [none, low, medium, high]_ to set the threshold\n'; - temp += '__Severities:__\n*none* - unmute, unban\n*low* - mute\n*medium* - kick\n*high* - ban\nEvery tier also includes all notifs for ***higher*** tiers (AKA _!setup log\\_severity none_ will log everything from every severity)\n'; - } else if (args[1] == 'announcement') { - temp = "To pick the announcement channel, use _!setup announcement\\_channel_\nTo pick the announcement role, use _!setup announcement\\_role_"; - } else { temp = 'Use _!setup Please use the following format: _!setup help [welcome, logs, announcement]_\nExample: _!setup help welcome_'; } - - message.reply(temp); + message.reply(temp); + } + } catch (err) { + console.error(err); } }); } diff --git a/commands/premium/twitchnotifs.js b/commands/premium/twitchnotifs.js new file mode 100644 index 0000000..0a036ab --- /dev/null +++ b/commands/premium/twitchnotifs.js @@ -0,0 +1,4 @@ +/* TODO + 1) Save by streamer id, with the users to ping inside + 2) Check the streamers every 5 min or so +*/ \ No newline at end of file