master
Kit Kasune 4 years ago
parent 79f3029103
commit 9b0029cf37
  1. 27
      commands/ar.js
  2. 2
      util/mention.js

@ -44,14 +44,15 @@ module.exports = {
} }
if (['a', 'add'].includes(args[0].toLowerCase())) { if (['a', 'add'].includes(args[0].toLowerCase())) {
let trigger = await ask(message, "What would you like the trigger to be? This is the message that will make your AR work.", 120000); if (!trigger) {return null;} let trigger = await ask(message, "What would you like the trigger to be? This is the message that will make your AR work.", 120000); if (!trigger) {return;}
if (`${trigger}`.length > 150) {return message.channel.send("Your trigger needs to be less than 150 characters, please!");} if (`${trigger}`.length > 150) {return message.channel.send("Your trigger needs to be less than 150 characters, please!");}
let response = await ask(message, "What would you like my response to be?", 120000); if (!response) {return null;} console.log(trigger);
let response = await ask(message, "What would you like my response to be?", 120000); if (!response) {return;}
if (`${response}`.length > 300) {return message.channel.send("Your response needs to be less than 300 characters, please!");} if (`${response}`.length > 300) {return message.channel.send("Your response needs to be less than 300 characters, please!");}
let tar = await AR.findOne({gid: message.guild.id}) || new AR({gid: message.guild.id}); let tar = await AR.findOne({gid: message.guild.id}) || new AR({gid: message.guild.id});
if (tar.triggers.length === 20) {return message.channel.send("Because of data storage concerns, your ARs are capped at 20 per server. You can join the official support server and talk to the devs if you have a legitimate reason for raising this limit and they can see about raising it for you!");} if (tar.triggers.length === 20) {return message.channel.send("Because of data storage concerns, your ARs are capped at 20 per server. You can join the official support server and talk to the devs if you have a legitimate reason for raising this limit and they can see about raising it for you!");}
let h = false; let ar; for (ar of tar.triggers) {if (ar.toLowerCase() === `${trigger}`.toLowerCase()) {h = true;}} let h = false; let ar; for (ar of tar.triggers) {if (ar && ar.toLowerCase() === `${trigger}`.toLowerCase()) {h = true;}}
if (!h) {tar.triggers.push(trigger);} if (!h) {tar.triggers.push(trigger);}
client.misc.cache.ar.set(message.guild.id, tar.triggers); client.misc.cache.ar.set(message.guild.id, tar.triggers);
tar.ars[`${trigger}`.trim().toLowerCase()] = `${response}`.trim(); tar.ars[`${trigger}`.trim().toLowerCase()] = `${response}`.trim();
@ -61,7 +62,25 @@ module.exports = {
} }
if (['e', 'edit'].includes(args[0].toLowerCase())) { if (['e', 'edit'].includes(args[0].toLowerCase())) {
let tar = await AR.findOne({gid: message.guild.id});
if (!tar || !tar.triggers.length) {return message.channel.send("You can't edit any auto-responses... because there aren't any here...");}
let sar = sortARs(tar);
await message.channel.send(viewARs(sar[0]).addField("Editing", "Please say the **number** of the AR you wish to edit."));
let collected;
try {collected = await message.channel.awaitMessages(m => m.author.id === message.author.id, {errors: ['time'], time: 60001, max: 1});}
catch {return message.channel.send("This question has timed out. Please try again!");}
collected = collected.first().content.trim();
if (isNaN(Number(collected))) {return message.channel.send("Hmmm, maybe try replying with a *number*!");}
let id = Number(collected);
if (id < 1 || id > tar.triggers.length) {return message.channel.send("Your number was either below 1 or doesn't have a trigger to match it.");}
try {
let response = await ask(message, "What would you like the new response to be?", 120000); if (!response) {return;}
if (`${response}`.length > 300) {return message.channel.send("Your response needs to be less than 300 characters, please!");}
tar.ars[sar[1][id-1]] = response;
tar.save();
return message.channel.send("Yeah, that response seems to fit better than the last one.");
} catch {return message.channel.send("There seemed to have been a problem deleting that AR. Contact my devs if the problem persists.");}
} }
if (['d', 'delete'].includes(args[0].toLowerCase())) { if (['d', 'delete'].includes(args[0].toLowerCase())) {
@ -70,7 +89,7 @@ module.exports = {
let sar = sortARs(tar); let sar = sortARs(tar);
await message.channel.send(viewARs(sar[0]).addField("Deletion", "Please say the **number** of the AR you wish to delete.")); await message.channel.send(viewARs(sar[0]).addField("Deletion", "Please say the **number** of the AR you wish to delete."));
let collected let collected;
try {collected = await message.channel.awaitMessages(m => m.author.id === message.author.id, {errors: ['time'], time: 60000, max: 1});} try {collected = await message.channel.awaitMessages(m => m.author.id === message.author.id, {errors: ['time'], time: 60000, max: 1});}
catch {return message.channel.send("This question has timed out. Please try again!");} catch {return message.channel.send("This question has timed out. Please try again!");}
collected = collected.first().content.trim(); collected = collected.first().content.trim();

@ -15,6 +15,6 @@ module.exports = async(message, msg, args, cmd, prefix, mention, client) => {
let m = await message.channel.send(`That user ${tu.statustype === 'dnd' ? 'wishes not to be disturbed' : 'is AFK'}. Reason: ${tu.statusmsg}.${tu.statssetat ? ` \`(This status was set ${moment(tu.statussetat.getTime()).fromNow()})\`` : ''}`); let m = await message.channel.send(`That user ${tu.statustype === 'dnd' ? 'wishes not to be disturbed' : 'is AFK'}. Reason: ${tu.statusmsg}.${tu.statssetat ? ` \`(This status was set ${moment(tu.statussetat.getTime()).fromNow()})\`` : ''}`);
await require('../util/wait')(10000); await require('../util/wait')(10000);
m.delete().catch((e) => {console.log(e);}); m.delete().catch((e) => {console.log(e);});
console.log(m); //console.log(m);
} }
}; };
Loading…
Cancel
Save