add emote robbing

master
Kit Kasune 3 years ago
parent 437a8c7bd1
commit a0042b134e
  1. 28
      commands/utility/remind.js
  2. 74
      commands/utility/robemote.js
  3. 6
      util/ask.js

@ -17,20 +17,20 @@ module.exports = {
.addField("Syntax", "`remind <x days|x hours|x minutes>`"),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}remind <time> <days|hours|minutes> <reminder>\``);}
if (isNaN(args[0])) {return message.channel.send("You didn't provide a number for how long I should wait to remind you.");}
if (args[0].length > 8) {return message.channel.send("Whoah there, pal. That's a lot of time! A little too much, perhaps?");}
let time = Number(args[0]);
if (!args[1]) {return message.channel.send("You didn't provide the time format. Must be `<days|hours|minutes>`");}
if (!['days', 'day', 'd', 'hours', 'hour', 'h', 'minutes', 'minute', 'm'].includes(args[1].toLowerCase())) {return message.channel.send("You didn't provide a proper time format. Must be `days`, `hours`, or `minutes`.");}
let type = args[1].toLowerCase();
time = type.startsWith('m') ? time : type.startsWith('h') ? time * 60 : time * 60 * 24;
if (time > (60 * 24 * 14)) {return message.channel.send("Reminders are limited to less than 14 days.");}
if (!args[2]) {return message.channel.send("You have to tell me what you want me to remind you to do!");}
args.shift(); args.shift();
let reminder = args.join(" ");
if (reminder.length > 300) {return message.channel.send("Your reminder must be less than 300 characters.");}
let startDate = new Date(Date.now() + (1000 * 60 * time));
if (isNaN(args[0])) {return message.channel.send("You didn't provide a number for how long I should wait to remind you.");}
if (args[0].length > 8) {return message.channel.send("Whoah there, pal. That's a lot of time! A little too much, perhaps?");}
let time = Number(args[0]);
if (!args[1]) {return message.channel.send("You didn't provide the time format. Must be `<days|hours|minutes>`");}
if (!['days', 'day', 'd', 'hours', 'hour', 'h', 'minutes', 'minute', 'm'].includes(args[1].toLowerCase())) {return message.channel.send("You didn't provide a proper time format. Must be `days`, `hours`, or `minutes`.");}
let type = args[1].toLowerCase();
time = type.startsWith('m') ? time : type.startsWith('h') ? time * 60 : time * 60 * 24;
if (time > (60 * 24 * 14)) {return message.channel.send("Reminders are limited to less than 14 days.");}
if (!args[2]) {return message.channel.send("You have to tell me what you want me to remind you to do!");}
args.shift(); args.shift();
let reminder = args.join(" ");
if (reminder.length > 300) {return message.channel.send("Your reminder must be less than 300 characters.");}
let startDate = new Date(Date.now() + (1000 * 60 * time));
new cron.CronJob(startDate, () => message.author.send(`Here's a reminder you asked me to give you ${moment(new Date(Date.now() - (1000 * 60 * time))).fromNow()}: ${reminder}`).catch(() => {})).start();
return message.channel.send(`Reminder set! Make sure you have your DMs open, as it will send in DM.`);
return message.channel.send(`Reminder set! Make sure you have your DMs open, as it will send in DM.`);
}
};

@ -0,0 +1,74 @@
const Discord = require('discord.js');
module.exports = {
name: "robemote",
aliases: ['robemoji', 're', 'stealemoji', 'stealemote', 'addemote', 'createemote', 'createemoji', 'addemoji', 'ae'],
meta: {
category: 'Utility',
description: "Take any emote and instantly add it to your server!",
syntax: '`robemote [emoji|url] [name]`',
extra: null,
guildOnly: true
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Emoji Robbery")
.setDescription("Takes an emoji and adds it to this server, if you have the permissions.")
.addField("Syntax", "`robemote [emoji] [name]`"),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!message.member.permissions.has("MANAGE_EMOJI")) {return message.channel.send("You must have permissions to manage emoji in this server.");}
if (!message.guild.me.permissions.has("MANAGE_EMOJI")) {return message.channel.send("I don't have permissions to manage emoji in this server, so I can't add any emotes.");}
if (!args.length) {
return message.channel.send(new Discord.MessageEmbed()
.setTitle("Add Emoji")
.setDescription("React to this message with the emoji you want to be added to the server.")
.setFooter("This will time out in 60 seconds")
.setColor('c375f0')
).then(m => {
const rc = m.createReactionCollector((r, u) => u.id === message.author.id, {time: 60000});
rc.on('collect', r => {
rc.stop();
return message.guild.emojis.create(`https://cdn.discordapp.com/emojis/${r.emoji.id}`, r.emoji.name)
.then(e => message.channel.send(new Discord.MessageEmbed()
.setAuthor(message.member.displayName, message.author.avatarURL())
.setTitle("Emoji Created!")
.setThumbnail(`https://cdn.discordapp.com/emojis/${e.id}${e.animated ? '.gif': ''}`)
.setDescription(`Name: \`:${e.name}:\`\nID: ${e.id}\nURL: [Click Me](https://cdn.discordapp.com/emojis/${e.id})`)
.setFooter("Natsuki")
.setColor('c375f0')
.setTimestamp()
).then(() => require('../../util/ask')(message, "If you'd like to rename the emoji, send the name now. Otherwise, wait 30 seconds and nothing will happen.", 30000, false, false)
.then(res => {
if (res) {
e.setName(res)
.then(() => message.channel.send("Emoji successfully renamed!"))
.catch(() => {return message.channel.send("For some reason, the emoji was not able to be renamed. Please do so manually");});
}
})
)).catch(() => message.channel.send("<a:NC_x:717396078294597643> There was an error trying to create that emoji. I might not have permissions to add emoji, or the server may be at its emoji limit."));
});
rc.on('end', collected => {if (collected.size) {return m.delete().catch(() => {});} else {m.edit(m.embeds[0].setDescription(m.embeds[0].description + '\n\n*Timed out!*')).catch(() => {});}});
});
}
if (!args[0].match(/^<a?:.+:\d+>$|^https:\/\/.+$|^\d+$/)) {return message.channel.send("It doesn't look like you gave me a valid emoji to steal or a URL to make an emoji from.");}
if (!args[1] && !args[0].match(/^<a?:.+:\d+>$/)) {return message.channel.send("You specified a URL/ID but didn't give an emoji name. Please try again and give the name you'd like to make the emoji.");}
return message.guild.emojis.create(
args[0].match(/^<a?:.+:\d+>$/)
? `https://cdn.discordapp.com/emojis/${args[0].split(':')[2].slice(0, args[0].split(':')[2].length - 1)}`
: args[0].match(/^\d+$/)
? `https://cdn.discordapp.com/emojis/${args[0]}`
: args[0],
args[1] || args[0].split(':')[1]
).then(e => message.channel.send(new Discord.MessageEmbed()
.setAuthor(message.member.displayName, message.author.avatarURL())
.setTitle("Emoji Created!")
.setThumbnail(`https://cdn.discordapp.com/emojis/${e.id}${e.animated ? '.gif': ''}`)
.setDescription(`Name: \`:${e.name}:\`\nID: ${e.id}\nURL: [Click Me](https://cdn.discordapp.com/emojis/${e.id}${e.animated ? '.gif': ''})`)
.setFooter("Natsuki")
.setColor('c375f0')
.setTimestamp()
))
.catch(() => message.channel.send("<a:NC_x:717396078294597643> There was an error trying to create that emoji. I might not have permissions to add emoji, the server may be at its emoji limit, you may have given a bad URL, not specified the emoji properly, or the file type in the URL you gave is invalid."));
}
};

@ -1,12 +1,12 @@
module.exports = async (message, toAsk, time, nf) => {
module.exports = async (message, toAsk, time, nofilter, timeoutResponse) => {
let msg = await message.channel.send(toAsk);
let filter = nf ? () => true : m => m.author.id === message.author.id;
let filter = nofilter ? () => true : m => m.author.id === message.author.id;
try {
let collected = await msg.channel.awaitMessages(filter, {max: 1, errors: ['time'], time: time});
collected = collected.first().content;
return collected;
} catch {
message.reply("This question has timed out! Please try again.");
if (timeoutResponse) {message.reply("This question has timed out! Please try again.");}
return null;
}
};
Loading…
Cancel
Save