2020-01-25 10:02:43 +00:00
|
|
|
exports.run = async (client, message, args) => {
|
|
|
|
|
|
|
|
const settings = message.settings;
|
|
|
|
|
|
|
|
if (!client.settings.has(message.guild.id)) {
|
|
|
|
client.settings.set(message.guild.id, {});
|
|
|
|
}
|
|
|
|
|
2020-03-09 01:11:33 +00:00
|
|
|
var autorole = message.guild.roles.cache.get(settings.autorole)
|
2020-01-25 10:02:43 +00:00
|
|
|
|
|
|
|
if (!args[0]) {
|
|
|
|
if(!autorole) {
|
|
|
|
return message.channel.send(
|
|
|
|
`<:error:466995152976871434> There is no autorole set for this server. Please set one using \`${message.settings.prefix}autorole <role>\``
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
message.channel.send(`Users recieve this role upon joining: \`${autorole.name}\``)
|
|
|
|
}
|
|
|
|
|
2020-03-09 01:11:33 +00:00
|
|
|
} else if(args.join(" ").toLowerCase() == "off") {
|
|
|
|
if(settings.autorole == "off") {
|
|
|
|
return message.channel.send("<:error:466995152976871434> Autoroling has not been enabled.")
|
|
|
|
}
|
|
|
|
|
|
|
|
client.settings.set(message.guild.id, "off", "autorole");
|
|
|
|
return message.channel.send("<:success:466995111885144095> Autoroling has been disabled.")
|
2020-01-25 10:02:43 +00:00
|
|
|
} else {
|
2020-03-09 01:11:33 +00:00
|
|
|
|
2020-01-25 10:02:43 +00:00
|
|
|
const joinedValue = args.join(" ");
|
|
|
|
if (joinedValue.length < 1) {
|
|
|
|
return message.channel.send(
|
|
|
|
`<:error:466995152976871434> You didn't specify a role. Usage: \`${client.commands.get(`autorole`).help.usage}\``
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (settings.autorole != "off" && joinedValue === autorole.name) {
|
|
|
|
return message.channel.send(
|
|
|
|
"<:error:466995152976871434> The autorole is already set to that!"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-03-09 01:11:33 +00:00
|
|
|
role = client.findRole(joinedValue, message);
|
|
|
|
|
|
|
|
if (!role) {
|
|
|
|
return message.channel.send(`<:error:466995152976871434> That role doesn't seem to exist. Try again!`);
|
|
|
|
};
|
2020-01-25 10:02:43 +00:00
|
|
|
|
2020-03-09 01:11:33 +00:00
|
|
|
client.settings.set(message.guild.id, role.id, "autorole");
|
2020-01-25 10:02:43 +00:00
|
|
|
|
|
|
|
message.channel.send(
|
2020-03-09 01:11:33 +00:00
|
|
|
`<:success:466995111885144095> The autorole has been set to \`${role.name}\`
|
2020-01-25 10:02:43 +00:00
|
|
|
`);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.conf = {
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: [],
|
|
|
|
permLevel: "Administrator",
|
2020-03-09 01:11:33 +00:00
|
|
|
requiredPerms: ["MANAGE_ROLES"]
|
2020-01-25 10:02:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.help = {
|
|
|
|
name: "autorole",
|
|
|
|
category: "Configure",
|
|
|
|
description: "Sets the autorole for this server.",
|
|
|
|
usage: "autorole <role> **OR** autorole off"
|
|
|
|
};
|