Add joinrole command and functionality

master
Kit Kasune 4 years ago
parent cbd0bc3c42
commit 8a8b7c6bab
  1. 33
      commands/autorole.js
  2. 7
      commands/eval.js
  3. 2
      events/guildCreate.js
  4. 8
      events/guildMemberAdd.js

@ -0,0 +1,33 @@
const Discord = require('discord.js');
const GuildData = require('../models/guild');
module.exports = {
name: "autorole",
aliases: ['joinrole', 'jr'],
help: new Discord.MessageEmbed()
.setTitle("Help -> Auto Role/Join Role")
.setDescription("Set a role to be automatically added to users when they join the server.")
.addField("Syntax", "`autorole <set|clear|view>`")
.addField('Notice', "This command can only be used by server staff members and admins."),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!message.guild) {return message.reply("This command is only available in servers.");}
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}autorole <set|clear|view>\``);}
let tg = await GuildData.findOne({gid: message.guild.id}) ? await GuildData.findOne({gid: message.guild.id}) : new GuildData({gid: message.guild.id});
if (['v', 'view', 'check'].includes(args[0])) {return message.channel.send(tg.joinrole.length && message.guild.roles.cache.has(tg.joinrole) ? `I am currently adding \`${message.guild.roles.cache.get(tg.joinrole).name}\` to new members.` : "At the moment, I'm not adding a role to new members.");}
if ((!tg.staffrole.length || !message.member.roles.cache.has(tg.staffrole)) && !message.member.permissions.has("ADMINISTRATOR")) {return message.reply("You don't have the permissions to edit this setting.");}
if (['s', 'set', 'c', 'clear'].includes(args[0])) {
let role = message.mentions.roles.first() ? message.mentions.roles.first().id : args[1] && message.guild.roles.cache.has(args[1]) ? args[1] : ['c', 'clear'].includes(args[0]) ? '' : null;
if (role === null) {return message.reply("That doesn't seem to be a role!");}
tg.joinrole = role;
tg.save();
return message.channel.send(new Discord.MessageEmbed()
.setTitle("Join Role Updated")
.setThumbnail(message.author.avatarURL({size: 2048}))
.setDescription(`Role: ${tg.joinrole.length ? `<@&${tg.joinrole}>` : "None"}`)
.setColor("c375f0")
.setFooter('Natsuki', client.user.avatarURL())
.setTimestamp()
);
}
}
};

@ -1,18 +1,13 @@
const Discord = require('discord.js'); const Discord = require('discord.js');
const util = require('util');
const moment = require('moment');
const chalk = require('chalk');
module.exports = { module.exports = {
name: 'eval', name: 'eval',
aliases: ['ev', ':'], aliases: ['ev', ':', 'e'],
help: "Evaluates raw JavaScript code. *This is a __developer-only__ command.* Usage: `{{p}}eval <code>`", help: "Evaluates raw JavaScript code. *This is a __developer-only__ command.* Usage: `{{p}}eval <code>`",
execute(message, msg, args, cmd, prefix, mention, client) { execute(message, msg, args, cmd, prefix, mention, client) {
try { try {
if (!client.developers.includes(message.author.id)) return; if (!client.developers.includes(message.author.id)) return;
let kieran = client.users.cache.get('673477059904929802').tag
if (!args.length) return message.channel.send(`Syntax: \`${prefix}eval <code>\``); if (!args.length) return message.channel.send(`Syntax: \`${prefix}eval <code>\``);
const result = new Promise((resolve) => resolve(eval(args.join(' ')))); const result = new Promise((resolve) => resolve(eval(args.join(' '))));
return result.then((output) => { return result.then((output) => {

@ -18,7 +18,7 @@ module.exports = async (client, guild) => {
.setAuthor('New Guild Added', guild.owner.avatarURL()) .setAuthor('New Guild Added', guild.owner.avatarURL())
.setTitle(guild.name) .setTitle(guild.name)
.setThumbnail(guild.iconURL({size: 2048})) .setThumbnail(guild.iconURL({size: 2048}))
.addField('Owner', guild.owner.tag, true) .addField('Owner', client.users.cache.get(guild.owner.id).tag, true)
.addField('Members', guild.members.cache.size) .addField('Members', guild.members.cache.size)
.addField('Position', `Server #${client.guilds.cache.size}`) .addField('Position', `Server #${client.guilds.cache.size}`)
.setColor('55ff7f') .setColor('55ff7f')

@ -0,0 +1,8 @@
const GuildData = require('../models/guild');
module.exports = async (client, member) => {
let tg = await GuildData.findOne({gid: member.guild.id});
if (tg && tg.joinrole.length && member.guild.roles.cache.has(tg.joinrole)) {
if (member.guild.members.cache.get(client.user.id).permissions.has("MANAGE_ROLES")) {member.roles.add(tg.joinrole);}
}
};
Loading…
Cancel
Save