Added new command: vip

master
Kit Kasune 4 years ago
parent 8a64b6fcb8
commit dda37b7893
  1. 2
      bot.js
  2. 48
      commands/vip.js
  3. 2
      events/ready.js
  4. 23
      models/guild.js

@ -13,5 +13,7 @@ async function init() {
['command', 'event'].forEach(x => require(`./handle/${x}`)(client)); ['command', 'event'].forEach(x => require(`./handle/${x}`)(client));
client.developers = ["330547934951112705", "673477059904929802"]; client.developers = ["330547934951112705", "673477059904929802"];
client.utils = {};
client.utils.logch = async () => {return client.guilds.cache.get('762707532417335296').channels.cache.get('762732961753595915');};
} }
init(); init();

@ -0,0 +1,48 @@
const Discord = require("discord.js");
module.exports = {
name: "vip",
aliases: ["premium"],
help: new Discord.MessageEmbed()
.setTitle("Help -> VIP")
.setDescription("Toggle a server as VIP. This allows ")
.addField("Syntax", "`vip <add|remove|check>`")
.addField("Notice", "This command is **developer-only**."),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!message.guild) {return message.reply("This command is server-only!");}
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}vip <add|remove|check>\``);}
if (!client.developers.includes(message.author.id) && !['check', 'c', 'view', 'v'].includes(args[0])) {return message.reply("Unfortunately, this is a **developer-only command**!");}
const GuildSettings = require('../models/guild');
const logemb = (act) => new Discord.MessageEmbed()
.setAuthor(`VIP Server ${act}`, message.author.avatarURL())
.setDescription("A Server's VIP status was updated.")
.setThumbnail(message.guild.iconURL({size: 1024}))
.addField("Name", message.guild.name, true)
.addField("Admin", message.author.username, true)
.setColor("e8da3a")
.setFooter("Natsuki")
.setTimestamp();
if (['add', 'a', 'make', 'm'].includes(args[0])) {
let tguild = await GuildSettings.findOne({gid: message.guild.id})
? await GuildSettings.findOne({gid: message.guild.id})
: new GuildSettings({gid: message.guild.id});
if (tguild.vip === true) {return message.reply("This server is already a VIP server.");}
tguild.vip = true;
tguild.save();
client.guilds.cache.get('762707532417335296').channels.cache.get('762732961753595915').send(logemb("Added"));
return message.reply("This server is now a VIP server!");
} else if (['remove', 'r', 'delete', 'd'].includes(args[0])) {
let tguild = await GuildSettings.findOne({gid: message.guild.id});
if (tguild) {
if (tguild.vip === false) {return message.reply("This server wasn't a VIP server anyways...");}
await GuildSettings.findOneAndUpdate({gid: message.guild.id, vip: false});
client.guilds.cache.get('762707532417335296').channels.cache.get('762732961753595915').send(logemb("Removed"));
} else {return message.reply("This server wasn't a VIP server anyways...");}
return message.reply("This server is no longer a VIP server!");
} else if (['check', 'c', 'view', 'v'].includes(args[0])) {
let tguild = await GuildSettings.findOne({gid: message.guild.id});
return message.reply((tguild && tguild.vip) ? 'This server is a VIP server.' : 'This server is not a VIP server.');
}
}
};

@ -9,7 +9,7 @@ module.exports = async client => {
const config = client.config; const config = client.config;
try { try {
await mongoose.connect(`mongodb+srv://${config.database.user}:${config.database.password}@${config.database.cluster}.3jpp4.mongodb.net/test`, { await mongoose.connect(`mongodb+srv://${config.database.user}:${config.database.password}@${config.database.cluster}.3jpp4.mongodb.net/test`, {
useFindAndModify: false, useNewUrlParser: true, dbName: 'Natsuki-Main', useUnifiedTopology: true useFindAndModify: false, useNewUrlParser: true, dbName: 'Natsuki-Main', useUnifiedTopology: true, useCreateIndex: true
}); });
} catch (e) { } catch (e) {
let date = new Date; date = date.toString().slice(date.toString().search(":") - 2, date.toString().search(":") + 6); let date = new Date; date = date.toString().slice(date.toString().search(":") - 2, date.toString().search(":") + 6);

@ -2,17 +2,18 @@ const mongoose = require('mongoose');
const guildSchema = new mongoose.Schema({ const guildSchema = new mongoose.Schema({
gid: {type: String, unique: true}, gid: {type: String, unique: true},
staffrole: String, staffrole: {type: String, default: ''},
vip: Boolean, vip: {type: Boolean, default: false},
wch: String, wch: {type: String, default: ''},
lch: String, lch: {type: String, default: ''},
logch: String, logch: {type: String, default: ''},
chests: String, chests: {type: Boolean, default: false},
autoquote: String, autoquote: {type: Boolean, default: true},
welcomeroll: String, welcomerole: {type: String, default: ''},
joinrole: String, joinrole: {type: String, default: ''},
cooldowns: Boolean, cooldowns: {type: Boolean, default: false},
levelmessage: String levelmessage: {type: String, default: '**{{u}}** has reached level **{{l}}**! :tada:'},
levelmessages: {type: Boolean, default: false}
}); });
module.exports = mongoose.model("guild", guildSchema); module.exports = mongoose.model("guild", guildSchema);
Loading…
Cancel
Save