Added channel, allow using a mention on hackban and snowflake

This commit is contained in:
TheEssem 2020-04-09 21:40:52 -05:00
parent 56b382fce3
commit 628a002205
7 changed files with 117 additions and 67 deletions

35
commands/channel.js Normal file
View file

@ -0,0 +1,35 @@
const db = require("../utils/database.js");
exports.run = async (message, args) => {
if (args.length === 0) return `${message.author.mention}, you need to provide whether I should be enabled or disabled in this channel!`;
if (args[0] !== "disable" && args[0] !== "enable") return `${message.author.mention}, that's not a valid option!`;
const guildDB = (await db.guilds.find({id: message.channel.guild.id}).exec())[0];
if (args[0].toLowerCase() === "disable") {
if (args[1] && args[1].match(/^<?[@#]?[&!]?\d+>?$/) && args[1] >= 21154535154122752) {
const id = args[1].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", "");
console.log(id);
if (guildDB.disabledChannels.includes(id)) return `${message.author.mention}, I'm already disabled in this channel!`;
guildDB.disabledChannels.push(id);
} else {
if (guildDB.disabledChannels.includes(message.channel.id)) return `${message.author.mention}, I'm already disabled in this channel!`;
guildDB.disabledChannels.push(message.channel.id);
}
await guildDB.save();
return `${message.author.mention}, I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`;
} else if (args[0].toLowerCase() === "enable") {
if (args[1] && args[1].match(/^<?[@#]?[&!]?\d+>?$/) && args[1] >= 21154535154122752) {
const id = args[1].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", "");
if (!guildDB.disabledChannels.includes(id)) return `${message.author.mention}, I'm not disabled in that channel!`;
guildDB.disabledChannels = guildDB.disabledChannels.filter(item => item !== id);
} else {
if (!guildDB.disabledChannels.includes(message.channel.id)) return `${message.author.mention}, I'm not disabled in this channel!`;
guildDB.disabledChannels = guildDB.disabledChannels.filter(item => item !== message.channel.id );
}
await guildDB.save();
return `${message.author.mention}, I have been re-enabled in this channel.`;
}
};
exports.category = 1;
exports.help = "Enables/disables me in a channel";
exports.params = "[enable/disable] {id}";

View file

@ -1,8 +1,9 @@
exports.run = async (message, args) => {
if (!args[0].match(/^\d+$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`;
if (!args[0].match(/^<?[@#]?[&!]?\d+>?$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`;
try {
await message.channel.guild.banMember(args[0], 0, `hackban command used by @${message.author.username}#${message.author.discriminator}`);
return `Successfully banned user with ID \`${args[0]}\`.`;
const id = args[0].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", "");
await message.channel.guild.banMember(id, 0, `Hackban command used by @${message.author.username}#${message.author.discriminator}`);
return `Successfully banned user with ID \`${id}\`.`;
} catch (e) {
throw e;
//return `${message.author.mention}, I was unable to ban the member. Have you given me permissions?`;

View file

@ -1,7 +1,7 @@
exports.run = async (message, args) => {
if (!args[0]) return `${message.author.mention}, you need to provide a snowflake ID!`;
if (!args[0].match(/^\d+$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`;
return new Date((args[0] / 4194304) + 1420070400000).toUTCString();
if (!args[0].match(/^<?[@#]?[&!]?\d+>?$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`;
return new Date((args[0].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", "") / 4194304) + 1420070400000).toUTCString();
};
exports.aliases = ["timestamp", "snowstamp", "snow"];