mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-15 05:36:54 +00:00
Transitioned all Misc, audio, Selmer Specific, admin, anime/manga, and inventory commands to Slash Command format. The RSS and reactionrole commands are still broken and all game commands are still in message format due to compications
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
const fs = require('fs');
|
||||
const {Buffer} = require('buffer');
|
||||
|
||||
function mapToObj(map){
|
||||
const obj = {}
|
||||
for (let [k,v] of map) {
|
||||
obj[k] = v
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
function objToMap(obj) {
|
||||
const m = new Map();
|
||||
for (i in obj) {
|
||||
m.set(i, obj[i]);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
async function backupLists(bot, IDM) {
|
||||
try {
|
||||
var backups = {}
|
||||
backups.locked = mapToObj(bot.lockedChannels);
|
||||
const bts = JSON.stringify({ "backups": backups });
|
||||
|
||||
if (IDM) {
|
||||
fs.writeFile('commands/admin/backup.json', bts, 'utf8', (err) => {
|
||||
// error checking
|
||||
if(err) throw err;
|
||||
|
||||
console.log("New data added: " + bts);
|
||||
process.exit(0);
|
||||
});
|
||||
} else {
|
||||
process.env.backupLists = bts;
|
||||
process.exit(0);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function loadBotBackups(bot, IDM) {
|
||||
try {
|
||||
if (IDM) {
|
||||
const botBackups = require('./backup.json').backups;
|
||||
bot.lockedChannels = objToMap(botBackups.locked);
|
||||
} else {
|
||||
bot.lockedChannels = objToMap(JSON.parse(botBackups.locked));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
bot.lockedChannels = new Map();
|
||||
const a = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { backupLists, loadBotBackups }
|
||||
@@ -1,28 +1,31 @@
|
||||
const { checkRole } = require('./verify.js');
|
||||
|
||||
const { Constants } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'lock',
|
||||
description: 'Lock a channel',
|
||||
execute(message, args, Discord, Client, bot) {
|
||||
const guild = bot.guilds.cache.get(message.guild.id);
|
||||
execute(interaction, Discord, Client, bot) {
|
||||
const arg = interaction.options.data[0];
|
||||
const guild = bot.guilds.cache.get(interaction.guildId);
|
||||
|
||||
if (!checkRole(bot, guild, message.author.id)) { return message.reply('Insufficient Permissions!'); }
|
||||
if (!checkRole(bot, guild, interaction.user.id)) { return interaction.reply('Insufficient Permissions!'); }
|
||||
|
||||
var channel;
|
||||
if (args[0]) {
|
||||
channel = guild.channels.cache.find(channel => channel.name.toLowerCase() === args[0]);
|
||||
if (arg) {
|
||||
channel = arg.channel;
|
||||
} else {
|
||||
channel = message.channel;
|
||||
channel = interaction.channel;
|
||||
}
|
||||
|
||||
if (!channel) { return message.reply("This channel does not exist!"); }
|
||||
|
||||
channel.permissionOverwrites.edit(message.guild.roles.everyone.id, {
|
||||
let role = interaction.guild.roles.cache.find(r => r.name === "@everyone");
|
||||
channel.permissionOverwrites.edit(role.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
SEND_MESSAGES: false,
|
||||
READ_MESSAGE_HISTORY: true,
|
||||
ATTACH_FILES: false
|
||||
});
|
||||
}
|
||||
|
||||
interaction.reply(`${channel} has been locked!`);
|
||||
},
|
||||
options: [{name: 'channel', description: 'The channel to lock (defaults to current channel)', type: Constants.ApplicationCommandOptionTypes.CHANNEL, required: false}]
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
//@ts-check
|
||||
const { log, SEVCODES } = require('../log.js');
|
||||
const { checkRole } = require('./verify.js');
|
||||
const { Constants } = require('discord.js');
|
||||
|
||||
|
||||
function modHelp() {
|
||||
@@ -15,7 +16,7 @@ function kick(guild, user) {
|
||||
}
|
||||
|
||||
|
||||
async function toggle_ban(guild, message, args, ban, reason) {
|
||||
async function toggle_ban(guild, interaction, args, ban, reason) {
|
||||
|
||||
if (ban) {
|
||||
guild.members.ban(args);
|
||||
@@ -27,7 +28,7 @@ async function toggle_ban(guild, message, args, ban, reason) {
|
||||
i++
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
message.guild.bans.fetch().then((users) => {
|
||||
interaction.guild.bans.fetch().then((users) => {
|
||||
const userObj = users.filter((u) => {
|
||||
return (`${u.user.username}#${u.user.discriminator}` == user);
|
||||
}).first();
|
||||
@@ -51,29 +52,29 @@ async function toggle_ban(guild, message, args, ban, reason) {
|
||||
}
|
||||
|
||||
|
||||
function toggle_mute(bot, guild, command, message, user, reason, mute) {
|
||||
function toggle_mute(bot, guild, command, interaction, user, reason, mute) {
|
||||
const mutedRole = guild.roles.cache.find((role) => role.name.toLowerCase() === 'muted');
|
||||
const guser = guild.members.cache.get(user.id);
|
||||
// if there is no `Muted` role, send an error
|
||||
if (!mutedRole) { return message.channel.send('There is no "muted" role on this server. Please create one then try again'); }
|
||||
if (!mutedRole) { return interaction.reply('There is no "muted" role on this server. Please create one then try again'); }
|
||||
|
||||
if (mute) {
|
||||
if (guser.roles.cache.get(mutedRole.id) == undefined) {
|
||||
guser.roles.add(mutedRole);
|
||||
log(bot, message, command, user, reason, SEVCODES.low);
|
||||
} else { message.reply("This user is already muted!"); }
|
||||
log(bot, interaction, command, user, reason, SEVCODES.low);
|
||||
} else { interaction.reply("This user is already muted!"); }
|
||||
} else {
|
||||
if (guser.roles.cache.get(mutedRole.id) != undefined) {
|
||||
guser.roles.remove(mutedRole);
|
||||
log(bot, message, command, user, reason, SEVCODES.none);
|
||||
} else { message.reply("This user is not muted!"); }
|
||||
log(bot, interaction, command, user, reason, SEVCODES.none);
|
||||
} else { interaction.reply("This user is not muted!"); }
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE: use the following function for a "time out" type thing?
|
||||
setTimeout(() => {
|
||||
target.roles.remove(mutedRole); // remove the role
|
||||
}, <time>)
|
||||
}, <time>)
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -94,43 +95,47 @@ function timeOut(bot, user, message, args, command, reason) {
|
||||
}
|
||||
|
||||
|
||||
function moderation_handler(bot, message, args, command) {
|
||||
const guild = message.guild;
|
||||
function moderation_handler(bot, interaction, command) {
|
||||
const guild = interaction.guild;
|
||||
|
||||
//Verify
|
||||
if (!checkRole(bot, guild, message.author.id)) { return message.reply('Insufficient Permission!'); }
|
||||
if (!checkRole(bot, guild, interaction.user.id)) { return interaction.reply('Insufficient Permission!'); }
|
||||
|
||||
let mentioned = message.mentions.users.first();
|
||||
if (mentioned && mentioned.id == message.author.id) { return message.reply(`You can't ${command} yourself!`); }
|
||||
const mentioned = interaction.options.data.filter((arg) => { return (arg.name == 'user'); })[0].user;
|
||||
if (mentioned && mentioned.id == interaction.user.id) { return interaction.reply(`You can't ${command} yourself!`); }
|
||||
|
||||
const reason = args.slice(1).join(' ');
|
||||
const reasonInit = interaction.options.data.filter((arg) => { return (arg.name == 'reason'); })[0];
|
||||
const reason = (reasonInit) ? reasonInit.value : "None";
|
||||
|
||||
if (message.mentions.members.first() && (message.mentions.members.first().roles.highest.position > message.guild.members.resolve(bot.user).roles.highest.position)) {
|
||||
return message.reply("I'm not high enough in the role hierarchy to do that!\n_To raise my place, go to **Server Settings -> Roles** then drag me up!_");
|
||||
const user = guild.members.resolve(mentioned.id);
|
||||
|
||||
if (user && (user.roles.highest.position > guild.members.resolve(bot.user).roles.highest.position)) {
|
||||
return interaction.reply("I'm not high enough in the role hierarchy to do that!\n_To raise my place, go to **Server Settings -> Roles** then drag me up!_");
|
||||
}
|
||||
|
||||
|
||||
if (command != 'unban' && !mentioned || !reason) { return message.channel.send(`Please use the following format: _!<command> <user> <reason>`); }
|
||||
if (command == 'unban' && !args[0] && !reason) { return message.channel.send("Please use the following format: _!unban <user_tag>#<user_discriminator> <reason>\nExample: _!unban John#1122_"); }
|
||||
// if (command != 'unban' && !mentioned || !reason) { return message.channel.send(`Please use the following format: _!<command> <user> <reason>`); }
|
||||
// if (command == 'unban' && !args[0] && !reason) { return message.channel.send("Please use the following format: _!unban <user_tag>#<user_discriminator> <reason>\nExample: _!unban John#1122_"); }
|
||||
// if (command == 'ban' && guild.members.cache.get(mentioned.id).bannable) { message.reply("This user is not bannable!"); } //Broken
|
||||
// if (command == 'ban' && !message.guild.members.cache.get(mentioned.id)) { message.reply("This user is not in the server"); }
|
||||
|
||||
switch (command) {
|
||||
case 'kick': kick(guild, mentioned);
|
||||
log(bot, message, command, mentioned, reason, SEVCODES.medium);
|
||||
log(bot, interaction, command, mentioned, reason, SEVCODES.medium);
|
||||
break;
|
||||
|
||||
case 'ban': toggle_ban(guild, message, mentioned, true, reason);
|
||||
log(bot, message, command, mentioned, reason, SEVCODES.high);
|
||||
case 'ban': toggle_ban(guild, interaction, mentioned, true, reason);
|
||||
log(bot, interaction, command, mentioned, reason, SEVCODES.high);
|
||||
break;
|
||||
|
||||
//Leave the then() catch() thing, it needs to be async
|
||||
case 'unban': toggle_ban(guild, message, args, false, reason).then((user) => { log(bot, message, command, user, reason, SEVCODES.none)}).catch((note) => { message.reply(note); });
|
||||
case 'unban': toggle_ban(guild, interaction, false, reason).then((user) => { log(bot, interaction, command, user, reason, SEVCODES.none)}).catch((note) => { interaction.reply(note); });
|
||||
break;
|
||||
|
||||
case 'mute': toggle_mute(bot, guild, command, message, mentioned, reason, true);
|
||||
case 'mute': toggle_mute(bot, guild, command, interaction, mentioned, reason, true);
|
||||
break;
|
||||
|
||||
case 'unmute': toggle_mute(bot, guild, command, message, mentioned, reason, true);
|
||||
case 'unmute': toggle_mute(bot, guild, command, interaction, mentioned, reason, true);
|
||||
break;
|
||||
|
||||
// case 'timeout': timeOut(bot, mentioned, message, args, command, reason);
|
||||
@@ -143,5 +148,5 @@ function moderation_handler(bot, message, args, command) {
|
||||
|
||||
module.exports = {
|
||||
name: 'moderation',
|
||||
moderation_handler, modHelp
|
||||
moderation_handler, modHelp,
|
||||
}
|
||||
@@ -1,18 +1,36 @@
|
||||
module.exports = {
|
||||
name: 'serverLock',
|
||||
description: 'Lock ***ALL CHANNELS*** for everyone with the "everyone" role - ***SERVER OWNER ONLY. FOR EMERGENCY USE ONLY***',
|
||||
execute(message, args, Discord, Client, bot) {
|
||||
const guild = bot.guilds.cache.get(message.guild.id);
|
||||
name: 'serverlock',
|
||||
description: 'Lock ALL CHANNELS for everyone with the "everyone" role - SERVER OWNER ONLY!',
|
||||
execute(interaction, Discord, Client, bot) {
|
||||
if (interaction.guild.ownerId != interaction.user.id) { return interaction.reply('Insufficient Permissions!'); }
|
||||
|
||||
if (guild.ownerId != message.author.id) { return message.reply('Insufficient Permissions!'); }
|
||||
const role = interaction.guild.roles.cache.find(r => r.name === "@everyone");
|
||||
const arr = [];
|
||||
|
||||
message.guild.channels.cache.forEach(ch => {
|
||||
channel.permissionOverwrites.edit(message.guild.roles.everyone.id, {
|
||||
VIEW_CHANNEL: false,
|
||||
SEND_MESSAGES: false,
|
||||
READ_MESSAGE_HISTORY: false,
|
||||
ATTACH_FILES: false
|
||||
});
|
||||
interaction.guild.channels.cache.forEach(channel => {
|
||||
if (channel.permissionsFor(role).has("SEND_MESSAGES")) {
|
||||
channel.permissionOverwrites.edit(role.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
SEND_MESSAGES: false,
|
||||
READ_MESSAGE_HISTORY: true,
|
||||
ATTACH_FILES: false
|
||||
});
|
||||
|
||||
//Maybe add the message to the array to be edited/deleted after unlock
|
||||
if (channel.type == 'GUILD_TEXT') {
|
||||
channel.send(`***CHANNEL LOCKED BY ${interaction.user}***`);
|
||||
}
|
||||
|
||||
arr.push(channel.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bot.lockedChannels.set(interaction.guildId, arr);
|
||||
|
||||
interaction.reply(`***SERVER LOCKED BY ${interaction.user}***`);
|
||||
}, options: []
|
||||
}
|
||||
|
||||
// interaction.reply(```diff
|
||||
// - SERVER LOCKED
|
||||
// ```);
|
||||
@@ -1,21 +1,32 @@
|
||||
// const { checkRole } = require('./verify.js');
|
||||
//Maybe add a list to selmer Bot that adds the channels when locking
|
||||
|
||||
module.exports = {
|
||||
name: 'serverunlock',
|
||||
description: 'unlocks the channels locked using /serverlock',
|
||||
execute(interaction, Discord, Client, bot) {
|
||||
const guild = bot.guilds.cache.get(interaction.guildId);
|
||||
const role = interaction.guild.roles.cache.find(r => r.name === "@everyone");
|
||||
|
||||
// module.exports = {
|
||||
// name: 'serverUnlock',
|
||||
// description: 'unlocks ***ALL CHANNELS*** for everyone except the those with the "Selmer Bot Commands" role',
|
||||
// execute(message, args, Discord, Client, bot) {
|
||||
// const guild = bot.guilds.cache.get(message.guild.id);
|
||||
// if (!checkRole(bot, guild, message.author.id)) { return message.reply('Insufficient Permissions!'); }
|
||||
if (interaction.guild.ownerId != interaction.user.id) { return interaction.reply('Insufficient Permissions!'); }
|
||||
|
||||
// if (!checkRole(bot, guild, message.author.id)) { return message.reply('Insufficient Permissions!'); }
|
||||
const channelIds = bot.lockedChannels.get(interaction.guildId);
|
||||
|
||||
// message.guild.channels.cache.forEach(ch => {
|
||||
// channel.permissionOverwrites.edit(message.guild.roles.everyone.id, {
|
||||
// VIEW_CHANNEL: true,
|
||||
// SEND_MESSAGES: false,
|
||||
// READ_MESSAGE_HISTORY: false,
|
||||
// ATTACH_FILES: false
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
if (!channelIds) { return interaction.reply("No channels to unlock..."); }
|
||||
|
||||
channelIds.forEach(id => {
|
||||
const channel = guild.channels.cache.get(id);
|
||||
channel.permissionOverwrites.edit(role.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
SEND_MESSAGES: true,
|
||||
READ_MESSAGE_HISTORY: true,
|
||||
ATTACH_FILES: true
|
||||
});
|
||||
});
|
||||
|
||||
bot.lockedChannels.set(interaction.guildId, []);
|
||||
interaction.reply(`Channels unlocked by ${interaction.user}`);
|
||||
},
|
||||
options: []
|
||||
}
|
||||
+98
-91
@@ -1,5 +1,6 @@
|
||||
//@ts-check
|
||||
const { MongoClient, ServerApiVersion } = require('mongodb');
|
||||
const { Constants } = require('discord.js');
|
||||
const { CreateNewCollection } = require("../db/econ");
|
||||
|
||||
|
||||
@@ -10,108 +11,104 @@ async function setWelcomeChannel(dbo, message, channelname) {
|
||||
|
||||
|
||||
|
||||
async function execute(bot, message, args, command, Discord, mongouri, items, xp_collection) {
|
||||
const server = message.guild.id;
|
||||
const owner = message.guild.members.cache.get(message.guild.ownerId);
|
||||
async function execute(interaction, Discord, Client, bot) {
|
||||
const server = interaction.guildId;
|
||||
const owner = interaction.guild.members.cache.get(interaction.guild.ownerId);
|
||||
const args = interaction.options.data;
|
||||
|
||||
if (message.author.id != message.guild.ownerId) {
|
||||
return message.reply('Only the server owner can do this!');
|
||||
if (interaction.user.id != interaction.guild.ownerId) {
|
||||
return interaction.reply({content: 'Only the server owner can do this!', ephemeral: true});
|
||||
}
|
||||
|
||||
// // @ts-ignore
|
||||
// const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
|
||||
// if (client.writeConcern || client.writeConcern) {
|
||||
// client.close();
|
||||
// return message.reply("Something went wrong with the database, please try again later and contact support if this problem persists!");
|
||||
// }
|
||||
|
||||
bot.mongoconnection.then(async (client) => {
|
||||
// if (err) { return console.log(err); }
|
||||
try {
|
||||
//Initialize
|
||||
CreateNewCollection(message, client, server, owner.user.id);
|
||||
//Initialize
|
||||
CreateNewCollection(interaction, client, server, owner.user.id);
|
||||
|
||||
const db = client.db(server);
|
||||
const dbo = db.collection('SETUP');
|
||||
const db = client.db(server);
|
||||
const dbo = db.collection('SETUP');
|
||||
|
||||
//Chose the appropriate command
|
||||
command = args[0];
|
||||
if (args.length < 1) { return interaction.reply({content: "Please chose a valid option", ephemeral: true}); }
|
||||
|
||||
if (!command) {
|
||||
message.channel.send('Please use the following format _!setup help <welcome, logs>_');
|
||||
} else if (command == 'welcome_channel') {
|
||||
if (args.length != 2) { return message.reply('The command format is _!setup welcome_channel <channel name>_'); }
|
||||
// setWelcomeChannel(dbo, message, args[1]);
|
||||
const channel = message.guild.channels.cache.find(ch => ch.name === args[1]);
|
||||
if (!channel) { return message.reply('The specified channel does not exist!'); }
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
try {
|
||||
const command = args[i].name;
|
||||
|
||||
dbo.updateOne({welcomechannel: {$exists: true}}, {$set: {welcomechannel: `${channel.id}`}});
|
||||
message.reply(`Set ${channel} as the new welcome channel`)
|
||||
} else if (command == 'welcome_message') {
|
||||
if (args.length < 2) { return message.reply('The command format is _!setup welcome\\_message_\nUse _{sn}_ to insert the server name, _{un}_ to insert the user name, and _{ut}_ to insert the user tag\nExample: _!setup welcome\\_message Welcome to {sn} Sir {un}#{ut}_'); }
|
||||
let msg = "";
|
||||
for (let i = 1; i < args.length; i ++ ) {
|
||||
msg += args[i] + ' ';
|
||||
// if (!command) {
|
||||
// interaction.reply('Please use the following format _!setup help <welcome, logs>_');
|
||||
// } else
|
||||
|
||||
if (command == 'welcome_channel') {
|
||||
// if (args.length != 2) { return interaction.reply('The command format is _!setup welcome_channel <channel name>_'); }
|
||||
// setWelcomeChannel(dbo, message, args[1]);
|
||||
const channel = args[i].channel;
|
||||
|
||||
dbo.updateOne({welcomechannel: {$exists: true}}, {$set: {welcomechannel: `${channel.id}`}});
|
||||
interaction.reply({content: `Set ${channel} as the new welcome channel`, ephemeral: true})
|
||||
} else if (command == 'welcome_message') {
|
||||
// if (args.length < 2) { return interaction.reply('The command format is _!setup welcome\\_message_\nUse _{sn}_ to insert the server name, _{un}_ to insert the user name, and _{ut}_ to insert the user tag\nExample: _!setup welcome\\_message Welcome to {sn} Sir {un}#{ut}_'); }
|
||||
const msg = args[i].value;
|
||||
|
||||
if (msg.length > 30 || msg.length < 1) { return interaction.reply({content: 'Please specify a welcome message between 0 and 30 characters!', ephemeral: true}); }
|
||||
dbo.updateOne({welcomemessage: {$exists: true}}, {$set: {welcomemessage: msg}})
|
||||
} else if (command == 'keep_logs') {
|
||||
let keeplogs = args[i].value;
|
||||
|
||||
dbo.updateOne({ _id: 'LOG'}, {$set: {keepLogs: keeplogs}});
|
||||
|
||||
interaction.reply({content: `Toggled log keeping to ${keeplogs}. Please use _!setup log_channel_ to choose the log channel`, ephemeral: true});
|
||||
} else if (command == 'log_channel') {
|
||||
// if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup log\\_channel true_'); }
|
||||
|
||||
const channel = args[i].channel;
|
||||
if (!channel) { return interaction.reply({content: 'The specified channel does not exist!', ephemeral: true}); }
|
||||
|
||||
dbo.updateOne({_id: 'LOG'}, {$set: {logchannel: `${channel.id}`}});
|
||||
interaction.reply({content: `Made ${channel} the new Selmer Bot Logs channel!`, ephemeral: true});
|
||||
} else if (command == 'log_severity') {
|
||||
const tier = args[i].value;
|
||||
const l = ['none', 'low', 'medium', 'high'];
|
||||
if (!l.includes(tier)) { return interaction.reply({content: "Please select an existing tier ('none', 'low', 'medium', 'high')", ephemeral: true}); }
|
||||
|
||||
dbo.updateOne({_id: 'LOG'}, {$set: {severity: tier}})
|
||||
|
||||
interaction.reply({content: `Severity updated to ${tier}`, ephemeral: true});
|
||||
} else if (command == 'announcement_role') {
|
||||
const role = args[i].value;
|
||||
// if (message.mentions.roles.first() == undefined) {
|
||||
// return message.reply("Please mention a role (_!setup announcement\\_role **@role**_)\n_Note: Selmer Bot does NOT ping the @everyone role_");
|
||||
// }
|
||||
// const role = message.mentions.roles.first().id;
|
||||
dbo.updateOne({_id: 'announcement'}, { $set: { 'role': role.id } });
|
||||
|
||||
interaction.reply({content: `Role updated to ${role}`, ephemeral: true});
|
||||
} else if (command == "announcement_channel") {
|
||||
const channel = args[i].channel;
|
||||
if (!channel) { return interaction.reply({content: 'The specified channel does not exist!', ephemeral: true}); }
|
||||
|
||||
dbo.updateOne({_id: 'announcement'}, { $set: { 'channel': channel.id } });
|
||||
} else {
|
||||
interaction.reply({content: "Please chose a valid option", ephemeral: true});
|
||||
}
|
||||
/* Made obsolete by the change to Slash Commands
|
||||
|
||||
if (msg.length > 30) { return message.reply('Please specify a welcome message under 30 characters!'); }
|
||||
dbo.updateOne({welcomemessage: {$exists: true}}, {$set: {welcomemessage: msg}})
|
||||
} else if (command == 'keep_logs') {
|
||||
if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup keep\\_logs true'); }
|
||||
else if (command == 'help') {
|
||||
let temp;
|
||||
const subcat = args[i].value;
|
||||
if (args[1] == 'welcome') {
|
||||
temp = 'Use _/setup welcome\\_channel [channel name]_ to set the welcome channel and _/setup welcome\\_message [message]_ to set a welcome message/\n';
|
||||
} else if (args[1] == 'logs') {
|
||||
temp = 'To enable logging, use the command _/setup keep\\_logs true_ and _/setup log\\_channel_ [channel name] to set the logging channel/\n';
|
||||
temp += 'Use _/setup keep\\_logs false_ to disable logging and _/setup log\\_severity [none, low, medium, high]_ to set the threshold\n';
|
||||
temp += '__Severities:__\n*none* - unmute, unban\n*low* - mute\n*medium* - kick\n*high* - ban\nEvery tier also includes all notifs for ***higher*** tiers (AKA _/setup log\\_severity none_ will log everything from every severity)\n';
|
||||
} else if (args[1] == 'announcement') {
|
||||
temp = "To pick the announcement channel, use _/setup announcement\\_channel_\nTo pick the announcement role, use _/setup announcement\\_role_";
|
||||
} else { temp = 'Use _/setup Please use the following format: _/setup help [welcome, logs, announcement]_\nExample: _/setup help welcome_'; }
|
||||
|
||||
let keeplogs = false;
|
||||
if (args[1] == 'true') { keeplogs = true; }
|
||||
|
||||
dbo.updateOne({ _id: 'LOG'}, {$set: {keepLogs: keeplogs}});
|
||||
|
||||
message.reply(`Toggled log keeping to ${keeplogs}. Please use _!setup log_channel_ to choose the log channel`);
|
||||
} else if (command == 'log_channel') {
|
||||
if (args.length != 2) { return message.reply('Please specify a parameter\nExample: _!setup log\\_channel true_'); }
|
||||
|
||||
const channel = message.guild.channels.cache.find(ch => ch.name === args[1]);
|
||||
if (!channel) { return message.reply('The specified channel does not exist!'); }
|
||||
|
||||
dbo.updateOne({_id: 'LOG'}, {$set: {logchannel: `${channel.id}`}});
|
||||
message.reply(`Made ${channel} the new Selmer Bot Logs channel!`);
|
||||
} else if (command == 'log_severity') {
|
||||
const tier = args[1];
|
||||
const l = ['none', 'low', 'medium', 'high'];
|
||||
if (!l.includes(tier)) { return message.reply("Please select an existing tier ('none', 'low', 'medium', 'high')"); }
|
||||
|
||||
dbo.updateOne({_id: 'LOG'}, {$set: {severity: tier}})
|
||||
|
||||
message.reply("Severity updated!");
|
||||
} else if (command == 'announcement_role') {
|
||||
if (message.mentions.roles.first() == undefined) {
|
||||
return message.reply("Please mention a role (_!setup announcement\\_role **@role**_)\n_Note: Selmer Bot does NOT ping the @everyone role_");
|
||||
}
|
||||
const role = message.mentions.roles.first().id;
|
||||
dbo.updateOne({_id: 'announcement'}, { $set: { 'role': role } });
|
||||
|
||||
message.reply("Role updated!");
|
||||
} else if (command == "announcement_channel") {
|
||||
const channel = message.guild.channels.cache.find(ch => ch.name === args[1]);
|
||||
if (!channel) { return message.reply('The specified channel does not exist!'); }
|
||||
|
||||
dbo.updateOne({_id: 'announcement'}, { $set: { 'channel': channel.id } });
|
||||
interaction.reply({content: temp, ephemeral: true});
|
||||
}*/
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
else if (command == 'help') {
|
||||
let temp;
|
||||
if (args[1] == 'welcome') {
|
||||
temp = 'Use _!setup welcome\\_channel [channel name]_ to set the welcome channel and _!setup welcome\\_message [message]_ to set a welcome message!\n';
|
||||
} else if (args[1] == 'logs') {
|
||||
temp = 'To enable logging, use the command _!setup keep\\_logs true_ and _!setup log\\_channel_ [channel name] to set the logging channel!\n';
|
||||
temp += 'Use _!setup keep\\_logs false_ to disable logging and _!setup log\\_severity [none, low, medium, high]_ to set the threshold\n';
|
||||
temp += '__Severities:__\n*none* - unmute, unban\n*low* - mute\n*medium* - kick\n*high* - ban\nEvery tier also includes all notifs for ***higher*** tiers (AKA _!setup log\\_severity none_ will log everything from every severity)\n';
|
||||
} else if (args[1] == 'announcement') {
|
||||
temp = "To pick the announcement channel, use _!setup announcement\\_channel_\nTo pick the announcement role, use _!setup announcement\\_role_";
|
||||
} else { temp = 'Use _!setup Please use the following format: _!setup help [welcome, logs, announcement]_\nExample: _!setup help welcome_'; }
|
||||
|
||||
message.reply(temp);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -123,5 +120,15 @@ async function execute(bot, message, args, command, Discord, mongouri, items, xp
|
||||
module.exports = {
|
||||
name: 'setup',
|
||||
description: 'Set up server features',
|
||||
execute
|
||||
execute,
|
||||
options: [
|
||||
{name: 'welcome_channel', description: 'Sets the channel for welcome messages', type: Constants.ApplicationCommandOptionTypes.CHANNEL },
|
||||
{name: 'welcome_message', description: 'Sets the welcome message, Use {un} for username, {ut} for user tag and {sn} for server name', type: Constants.ApplicationCommandOptionTypes.STRING },
|
||||
{name: 'keep_logs', description: 'Toggles logging', type: Constants.ApplicationCommandOptionTypes.BOOLEAN },
|
||||
{name: 'log_channel', description: 'Sets the logging channel', type: Constants.ApplicationCommandOptionTypes.CHANNEL },
|
||||
{name: 'log_severity', description: 'Sets the logging Severity (logs this/lower tiers)', type: Constants.ApplicationCommandOptionTypes.STRING, choices: [{name: 'none', value: 'none'}, {name: 'low', value: 'low'}, {name: 'medium', value: 'medium'}, {name: 'high', value: 'high'}] },
|
||||
{name: 'announcement_role', description: 'Sets the role to be pinged for reminders', type: Constants.ApplicationCommandOptionTypes.ROLE},
|
||||
{name: 'announcement_channel', description: 'Sets the channel for reminders', type: Constants.ApplicationCommandOptionTypes.CHANNEL}
|
||||
// {name: 'help', description: 'gets help with setup commands', type: Constants.ApplicationCommandOptionTypes.STRING, choices: [{name: 'welcome', value: 'welcome'}, {name: 'logs', value: 'logs'}, {name: 'announcement', value: 'announcement'}]}
|
||||
]
|
||||
}
|
||||
@@ -1,28 +1,33 @@
|
||||
const { checkRole } = require('./verify.js');
|
||||
const { Constants } = require('discord.js');
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: 'unlock',
|
||||
description: 'Unlock a channel',
|
||||
execute(message, args, Discord, Client, bot) {
|
||||
const guild = bot.guilds.cache.get(message.guild.id);
|
||||
execute(interaction, Discord, Client, bot) {
|
||||
const arg = interaction.options.data[0];
|
||||
const guild = bot.guilds.cache.get(interaction.guildId);
|
||||
|
||||
if (!checkRole(bot, guild, message.author.id)) { return message.reply('Insufficient Permissions!'); }
|
||||
if (!checkRole(bot, guild, interaction.user.id)) { return message.reply('Insufficient Permissions!'); }
|
||||
|
||||
var channel;
|
||||
if (args[0]) {
|
||||
channel = guild.channels.cache.find(channel => channel.name.toLowerCase() === args[0]);
|
||||
if (arg) {
|
||||
channel = arg.channel;
|
||||
} else {
|
||||
channel = message.channel;
|
||||
channel = interaction.channel;
|
||||
}
|
||||
|
||||
if (!channel) { return message.reply("This channel does not exist!"); }
|
||||
let role = interaction.guild.roles.cache.find(r => r.name === "@everyone");
|
||||
|
||||
channel.permissionOverwrites.edit(message.guild.roles.everyone.id, {
|
||||
channel.permissionOverwrites.edit(role.id, {
|
||||
VIEW_CHANNEL: true,
|
||||
SEND_MESSAGES: true,
|
||||
READ_MESSAGE_HISTORY: true,
|
||||
ATTACH_FILES: true
|
||||
});
|
||||
}
|
||||
|
||||
interaction.reply(`${channel} has been unlocked!`);
|
||||
},
|
||||
options: [{name: 'channel', description: 'The channel to unlock (defaults to current channel)', type: Constants.ApplicationCommandOptionTypes.CHANNEL, required: false}]
|
||||
}
|
||||
Reference in New Issue
Block a user