From 92044152bf05b5f32ab3da41b9a1e1721f2cd759 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sat, 14 Nov 2020 20:05:12 -0700 Subject: [PATCH] cant be bothered to enter a commit message --- bot.js | 1 + commands/leave.js | 17 +++++++++++++++++ commands/response.js | 5 +++++ commands/secretsanta.js | 34 ++++++++++++++++++++++++++++++++++ commands/staffrole.js | 2 +- commands/welcome.js | 17 +++++++++++++++++ events/guildMemberAdd.js | 3 ++- events/guildMemberRemove.js | 3 ++- util/response/sendresponse.js | 6 ++++-- 9 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 commands/secretsanta.js diff --git a/bot.js b/bot.js index cc3127f..5919018 100644 --- a/bot.js +++ b/bot.js @@ -15,6 +15,7 @@ async function init() { client.developers = ["330547934951112705", "673477059904929802"]; client.misc = {}; client.misc.savers = ['497598953206841375']; + client.misc.activeDMs = new Discord.Collection(); client.utils = {}; client.utils.logch = async () => {return client.guilds.cache.get('762707532417335296').channels.cache.get('762732961753595915');}; diff --git a/commands/leave.js b/commands/leave.js index a40c0fb..c5a919e 100644 --- a/commands/leave.js +++ b/commands/leave.js @@ -45,5 +45,22 @@ module.exports = { if (!tr || !tr.bindings.has('leave') || !tr.responses.has(tr.bindings.get('leave'))) {return message.reply("I can't test your leave message because the response doesn't exist, a leave response isn't set, or you haven't made any responses in this server.");} await sendResponse(message.member, message.channel, 'this shit aint matter anymore lol', client, tr.responses.get(tr.bindings.get('leave'))); } + + if (['clear'].includes(args[0].toLowerCase())) { + tg.lch = ''; + tg.save(); + let tr = await Responses.findOne({gid: message.guild.id}) ? await Responses.findOne({gid: message.guild.id}) : new Responses({gid: message.guild.id}); + if (tr) { + tr.bindings.delete('leave'); + tr.save(); + } + return message.channel.send(new Discord.MessageEmbed() + .setTitle("Leave Channel/Message Updated") + .setDescription(`This server's leave-notifying settings have been altered by ${message.author.tag}.\n\n**Channel**: None`) + .setColor('c375f0') + .setFooter("Natsuki", client.user.avatarURL()) + .setTimestamp() + ); + } } }; \ No newline at end of file diff --git a/commands/response.js b/commands/response.js index cf3d5bb..e285dd9 100644 --- a/commands/response.js +++ b/commands/response.js @@ -66,6 +66,11 @@ module.exports = { if (hasBinding) {infoEmbed.addField("Server Bindings", bm);} return message.channel.send(infoEmbed); } + if (['edit', 'e', 'm', 'modify'].includes(args[0].toLowerCase())) { + let options = await getResponse(message, args[1]); + if (!options) {return;} + + } return message.channel.send(`Syntax: \`${prefix}response \``); diff --git a/commands/secretsanta.js b/commands/secretsanta.js new file mode 100644 index 0000000..ae12512 --- /dev/null +++ b/commands/secretsanta.js @@ -0,0 +1,34 @@ +const Discord = require('discord.js'); + +const ask = require('../util/ask'); + +module.exports = { + name: "secretsanta", + aliases: ['ss'], + help: new Discord.MessageEmbed() + .setTitle("Help -> Secret Santa") + .setDescription("Create a secret santa for all of your friends or for your server! Whether you celebrate the holidays or not, this can still be loads of fun!") + .addField("Syntax", "``"), + async execute(message, msg, args, cmd, prefix, mention, client) { + if (!args.length) {return message.channel.send(`Syntax: \`${prefix}\``);} + if (['start', 'create', 'new'].includes(args[0].toLowerCase())) { + if (client.misc.activeDMs.has(message.author.id)) {return message.reply("I'm already asking you questions in DM for a separate command! Finish that command before using this one.");} + client.misc.activeDMs.set(message.author.id, 'secretsanta-make'); + let mesg = await message.author.send("I'll be asking you a few questions here about how you want your Secret Santa to go! You can simply ignore the messages for a few minutes to cancel the process.").catch(() => {message.reply("Please open your DMs so I can ask you some questions!");}); + let dmch = mesg.channel; + + let conf = await ask(mesg, "This secret santa will be tied to your account, and you will be considered the host. Is this okay?", 60000); if (!conf) {return;} + if (['n', 'no'].includes(conf.trim().toLowerCase())) {return dmch.send("Oh, alrighty! Have the person who wants to be the host execute this same command.");} + if (!['yes', 'ye', 'y', 'sure'].includes(conf.trim().toLowerCase())) {return dmch.send("Please specify yes or no you weeb!");} + + let start = await ask(mesg, "When will you begin the secret santa? (You'll start it manually, so don't worry about formatting.", 60000); if (!start) {return;} + if (start.length > 150) {return dmch.send("Heya there, just a few words, please! I don't wanna have to read out an essay about when it's starting to all the people that want to hear about your secret santa!");} + + let end = await ask(mesg, "When will you end the secret santa? (You'll also end it manually.)", 60000); if (!start) {return;} + if (end.length > 150) {return dmch.send("Heya there, just a few words, please! I don't wanna have to read out an essay about when it's ending to all the people that want to hear about your secret santa!");} + + let spend = await ask(mesg, "What is your maximum and minimum spending? This is useful so that everyone gets an equal gift or gifts. This will be shown to the people that buy their gifts.", 360000); if (!join) {return;} + + } + } +}; \ No newline at end of file diff --git a/commands/staffrole.js b/commands/staffrole.js index 872c630..4b2e494 100644 --- a/commands/staffrole.js +++ b/commands/staffrole.js @@ -10,7 +10,7 @@ module.exports = { if (!message.guild) {return message.reply("This is a guild-only command!");} if (!args.length) {return message.channel.send(`Syntax: \`${prefix}staffrole <@role|roleID|clear|view>\``);} if (!message.member.permissions.has("ADMINISTRATOR")) {return message.reply("You must be an admin in this server in order to change this setting!");} - + let tguild = await GuildSettings.findOne({gid: message.guild.id}) ? await GuildSettings.findOne({gid: message.guild.id}) : new GuildSettings({gid: message.guild.id}); diff --git a/commands/welcome.js b/commands/welcome.js index 40a3adb..3ddade7 100644 --- a/commands/welcome.js +++ b/commands/welcome.js @@ -45,5 +45,22 @@ module.exports = { if (!tr || !tr.bindings.has('welcome') || !tr.responses.has(tr.bindings.get('welcome'))) {return message.reply("I can't test your welcome message because the response doesn't exist, a welcome response isn't set, or you haven't made any responses in this server.");} await sendResponse(message.member, message.channel, 'this shit aint matter anymore lol', client, tr.responses.get(tr.bindings.get('welcome'))); } + + if (['clear'].includes(args[0].toLowerCase())) { + tg.wch = ''; + tg.save(); + let tr = await Responses.findOne({gid: message.guild.id}) ? await Responses.findOne({gid: message.guild.id}) : new Responses({gid: message.guild.id}); + if (tr) { + tr.bindings.delete('welcome'); + tr.save(); + } + return message.channel.send(new Discord.MessageEmbed() + .setTitle("Welcome Channel/Message Updated") + .setDescription(`This server's member-welcoming settings have been altered by ${message.author.tag}.\n\n**Channel**: None`) + .setColor('c375f0') + .setFooter("Natsuki", client.user.avatarURL()) + .setTimestamp() + ); + } } }; \ No newline at end of file diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index 5985e4f..f837d38 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -12,7 +12,8 @@ module.exports = async (client, member) => { tr && tr.bindings.has('welcome') && tr.responses.has(tr.bindings.get('welcome')) && tg.wch.length && member.guild.channels.cache.has(tg.wch) && member.guild.channels.cache.get(tg.wch).permissionsFor(client.user.id).has("SEND_MESSAGES") + && !client.users.cache.get(member.id).bot ) { - member.guild.channels.cache.get(tg.wch).send(await sendResponse(member, member.guild.channels.cache.get(tg.wch), 'xdlol', client, tr.responses.get(tr.bindings.get('welcome')))); + try {member.guild.channels.cache.get(tg.wch).send(await sendResponse(member, member.guild.channels.cache.get(tg.wch), 'xdlol', client, tr.responses.get(tr.bindings.get('welcome'))));} catch {} } }; \ No newline at end of file diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js index 45691b3..63d8fcf 100644 --- a/events/guildMemberRemove.js +++ b/events/guildMemberRemove.js @@ -9,7 +9,8 @@ module.exports = async (client, member) => { tr && tr.bindings.has('leave') && tr.responses.has(tr.bindings.get('leave')) && tg.lch.length && member.guild.channels.cache.has(tg.lch) && member.guild.channels.cache.get(tg.lch).permissionsFor(client.user.id).has("SEND_MESSAGES") + && !client.users.cache.get(member.id).bot ) { - member.guild.channels.cache.get(tg.lch).send(await sendResponse(member, member.guild.channels.cache.get(tg.lch), 'xdlol', client, tr.responses.get(tr.bindings.get('leave')))); + try {member.guild.channels.cache.get(tg.lch).send(await sendResponse(member, member.guild.channels.cache.get(tg.lch), 'xdlol', client, tr.responses.get(tr.bindings.get('leave'))));} catch {} } }; \ No newline at end of file diff --git a/util/response/sendresponse.js b/util/response/sendresponse.js index 1b55938..74ec7e1 100644 --- a/util/response/sendresponse.js +++ b/util/response/sendresponse.js @@ -10,8 +10,10 @@ module.exports = async(member, channel, mode, client, options) => { var responseEmbed = new Discord.MessageEmbed().setTitle(options.title).setDescription(await filterResponse(member, client, options.description)); if (options.fieldnames && options.fieldnames.length) {let i; for (i=0;i