feat: init

This commit is contained in:
Nick 2024-08-10 02:53:40 -05:00
commit 8379d09058
11 changed files with 591 additions and 0 deletions

65
commands/baboon.js Normal file
View file

@ -0,0 +1,65 @@
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'baboon',
description: 'Strip all roles from a user and assign the role with ID 1160622954082738347.',
async execute(message) {
const authorizedRoles = ['827303828884946944', '827332588803850270'];
const userRoles = message.member.roles.cache.map(role => role.id);
console.log('User roles:', userRoles); // Debugging line
console.log('Authorized roles:', authorizedRoles); // Debugging line
if (!userRoles.some(role => authorizedRoles.includes(role))) {
return message.reply('You do not have permission to use this command.');
}
let target;
if (message.mentions.members.first()) {
target = message.mentions.members.first();
} else if (message.reference) {
target = await message.channel.messages.fetch(message.reference.messageId).then(msg => msg.member);
} else {
return message.reply('You have not targeted a user to baboon.');
}
console.log('Target user identified:', target.user.tag); // Debugging line
const roleID = '1160622954082738347';
const role = message.guild.roles.cache.get(roleID);
if (!role) {
return message.reply('Role not found.');
}
const previousRoles = target.roles.cache.filter(r => r.name !== '@everyone');
const rolesArray = previousRoles.map(role => role.id);
const filePath = path.join(__dirname, '../roles_backup.json');
let rolesBackup = {};
if (fs.existsSync(filePath)) {
rolesBackup = JSON.parse(fs.readFileSync(filePath, 'utf8'));
}
rolesBackup[target.id] = rolesArray;
fs.writeFileSync(filePath, JSON.stringify(rolesBackup, null, 2), 'utf8');
try {
await target.roles.remove(rolesArray);
await target.roles.add(role);
const logChannelID = '1028786996505759794'; // Replace with your actual channel ID
const logChannel = message.guild.channels.cache.get(logChannelID);
if (logChannel) {
message.channel.send(`${target.displayName} has become a ${role.name}! Check them out in ${logChannel.toString()}`);
} else {
console.error('Log channel not found');
}
} catch (error) {
console.error(error);
message.channel.send('Sorry, I am having trouble with my baboon gun.');
}
},
};

92
commands/coma.js Normal file
View file

@ -0,0 +1,92 @@
module.exports = {
name: 'coma',
description: 'Temporarily delete all messages and reactions of a user for 24 hours.',
async execute(message, args, comaUsers) {
try {
// Define role IDs
const authorizedRoles = ['969767633278869515', '827303828884946944', '827332588803850270'];
const targetRoleID = '1160622954082738347';
// Check if the command user has the authorized role
const userRoles = message.member.roles.cache.map(role => role.id);
console.log('User roles:', userRoles); // Debugging line
console.log('Authorized roles:', authorizedRoles); // Debugging line
if (!userRoles.some(role => authorizedRoles.includes(role))) {
return message.reply('You do not have permission to use this command.');
}
// Identify the target user
let target;
if (message.mentions.members.first()) {
target = message.mentions.members.first();
} else if (message.reference) {
target = await message.channel.messages.fetch(message.reference.messageId).then(msg => msg.member);
} else {
return message.reply('Please mention a user or reply to their message to use this command.');
}
// Check if the target user has the specific role
if (!target.roles.cache.has(targetRoleID)) {
return message.reply('The target user does not have the required role.');
}
// Define the time period to delete messages
const timePeriod = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
const now = Date.now();
// Fetch the target user's recent messages and delete them
const fetchOptions = {
limit: 100, // Fetch up to 100 messages per channel
};
// Function to delete messages in a channel
const deleteMessages = async (channel, userID) => {
const messages = await channel.messages.fetch(fetchOptions);
const userMessages = messages.filter(m => m.author.id === userID && (now - m.createdTimestamp) <= timePeriod);
for (const msg of userMessages.values()) {
await msg.delete();
}
};
// Function to remove reactions from messages in a channel
const removeReactions = async (channel, userID) => {
const messages = await channel.messages.fetch(fetchOptions);
const userMessages = messages.filter(m => m.author.id === userID && (now - m.createdTimestamp) <= timePeriod);
for (const msg of userMessages.values()) {
for (const reaction of msg.reactions.cache.values()) {
await reaction.users.remove(userID);
}
}
};
// Iterate through all channels and delete the target user's messages and reactions
for (const channel of message.guild.channels.cache.values()) {
if (channel.type === 'GUILD_TEXT') {
await deleteMessages(channel, target.id);
await removeReactions(channel, target.id);
}
}
// Add the user to the comaUsers set
comaUsers.add(target.id);
console.log(`Added ${target.id} to comaUsers`); // Debugging line
console.log(`Current comaUsers: ${Array.from(comaUsers)}`); // Debugging line
// Schedule removal from the comaUsers set after 24 hours
setTimeout(() => {
comaUsers.delete(target.id);
message.channel.send(`${target.displayName} is no longer comatose.`);
}, timePeriod);
// Send a confirmation message
message.channel.send(`${target.displayName} has received an overdose of tranquilizers and will be in a coma for 24 hours.`);
} catch (error) {
console.error('An error occurred:', error);
message.channel.send('There was an error trying to execute the command.');
}
},
};

60
commands/stim.js Normal file
View file

@ -0,0 +1,60 @@
module.exports = {
name: 'stim',
description: 'Cancel the tranquilization or coma effect of a user.',
async execute(message, args, tranqUsers, comaUsers) {
try {
// Define role IDs for authorized users
const authorizedRoles = ['969767633278869515', '827303828884946944', '827332588803850270'];
// Check if the command user has the authorized role
const userRoles = message.member.roles.cache.map(role => role.id);
console.log('User roles:', userRoles); // Debugging line
console.log('Authorized roles:', authorizedRoles); // Debugging line
if (!userRoles.some(role => authorizedRoles.includes(role))) {
return message.reply('You do not have permission to use this command.');
}
// Identify the target user
let target;
if (message.mentions.members.first()) {
target = message.mentions.members.first();
} else if (message.reference) {
target = await message.channel.messages.fetch(message.reference.messageId).then(msg => msg.member);
} else {
return message.reply('Please mention a user or reply to their message to use this command.');
}
// Ensure comaUsers and tranqUsers are initialized
if (!tranqUsers || !comaUsers) {
return message.reply('The user sets are not properly initialized.');
}
// Initialize confirmation message
let confirmationMessage = '';
// Debugging lines to check user status
console.log(`Checking status of user ${target.id}`);
console.log(`Is user in comaUsers: ${comaUsers.has(target.id)}`);
console.log(`Is user in tranqUsers: ${tranqUsers.has(target.id)}`);
// Remove user from both sets
const wasComatose = comaUsers.delete(target.id);
const wasTranquilized = tranqUsers.delete(target.id);
if (wasComatose || wasTranquilized) {
confirmationMessage = `${target.displayName} has been stimmed and is no longer tranquilized or in a coma.`;
console.log(`Removed ${target.id} from comaUsers or tranqUsers`); // Debugging line
} else {
return message.reply('The user is not currently tranquilized or in a coma.');
}
// Send the appropriate confirmation message
message.channel.send(confirmationMessage);
} catch (error) {
console.error('An error occurred:', error);
message.channel.send('There was an error trying to execute the command.');
}
},
};

90
commands/tranq.js Normal file
View file

@ -0,0 +1,90 @@
module.exports = {
name: 'tranq',
description: 'Temporarily delete all messages and reactions of a user for 10 minutes.',
async execute(message, args, tranqUsers) {
try {
// Define role IDs
const authorizedRoles = ['969767633278869515', '827303828884946944', '827332588803850270'];
const targetRoleID = '1160622954082738347';
// Check if the command user has the authorized role
const userRoles = message.member.roles.cache.map(role => role.id);
console.log('User roles:', userRoles); // Debugging line
console.log('Authorized roles:', authorizedRoles); // Debugging line
if (!userRoles.some(role => authorizedRoles.includes(role))) {
return message.reply('You do not have permission to use this command.');
}
// Identify the target user
let target;
if (message.mentions.members.first()) {
target = message.mentions.members.first();
} else if (message.reference) {
target = await message.channel.messages.fetch(message.reference.messageId).then(msg => msg.member);
} else {
return message.reply('Please mention a user or reply to their message to use this command.');
}
// Check if the target user has the specific role
if (!target.roles.cache.has(targetRoleID)) {
return message.reply('The target user does not have the required role.');
}
// Define the time period to delete messages
const timePeriod = 10 * 60 * 1000; // 10 minutes in milliseconds
const now = Date.now();
// Fetch the target user's recent messages and delete them
const fetchOptions = {
limit: 100, // Fetch up to 100 messages per channel
};
// Function to delete messages in a channel
const deleteMessages = async (channel, userID) => {
const messages = await channel.messages.fetch(fetchOptions);
const userMessages = messages.filter(m => m.author.id === userID && (now - m.createdTimestamp) <= timePeriod);
for (const msg of userMessages.values()) {
await msg.delete();
}
};
// Function to remove reactions from messages in a channel
const removeReactions = async (channel, userID) => {
const messages = await channel.messages.fetch(fetchOptions);
const userMessages = messages.filter(m => m.author.id === userID && (now - m.createdTimestamp) <= timePeriod);
for (const msg of userMessages.values()) {
for (const reaction of msg.reactions.cache.values()) {
await reaction.users.remove(userID);
}
}
};
// Iterate through all channels and delete the target user's messages and reactions
for (const channel of message.guild.channels.cache.values()) {
if (channel.type === 'GUILD_TEXT') {
await deleteMessages(channel, target.id);
await removeReactions(channel, target.id);
}
}
// Add the user to the tranqUsers set
tranqUsers.add(target.id);
// Schedule removal from the tranqUsers set after 10 minutes
setTimeout(() => {
tranqUsers.delete(target.id);
message.channel.send(`${target.displayName} is no longer tranquilized.`);
}, timePeriod);
// Send a confirmation message
message.channel.send(`${target.displayName} was becoming unruly and has been tranquilized for 10 minutes.`);
} catch (error) {
console.error('An error occurred:', error);
message.channel.send('There was an error trying to execute the command.');
}
},
};

75
commands/unbaboon.js Normal file
View file

@ -0,0 +1,75 @@
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'unbaboon',
description: 'Restore the roles of a user that were previously removed by the baboon command and remove the role with ID 1160622954082738347. If no cached roles are found, assign a default role.',
async execute(message) {
const authorizedRoles = ['827303828884946944', '827332588803850270'];
const userRoles = message.member.roles.cache.map(role => role.id);
console.log('User roles:', userRoles); // Debugging line
console.log('Authorized roles:', authorizedRoles); // Debugging line
if (!userRoles.some(role => authorizedRoles.includes(role))) {
return message.reply('You are not alpha enough to unbaboon other users.');
}
try {
// Identify the target user
let target;
if (message.mentions.members.first()) {
target = message.mentions.members.first();
} else if (message.reference) {
target = await message.channel.messages.fetch(message.reference.messageId).then(msg => msg.member);
} else {
return message.reply('Please tag the baboon you wish to rewild.');
}
console.log('Target user identified:', target.user.tag);
// Retrieve the bot's own member object
const botMember = await message.guild.members.fetch(message.client.user.id);
// Check if the bot has MANAGE_ROLES permission
if (!botMember.permissions.has('MANAGE_ROLES')) {
return message.reply('My kung fu is not strong enough.');
}
const roleID = '1160622954082738347';
const defaultRoleID = '964354344948494416';
const role = message.guild.roles.cache.get(roleID);
const defaultRole = message.guild.roles.cache.get(defaultRoleID);
if (!role) {
return message.reply('Role not found.');
}
if (!defaultRole) {
return message.reply('Default role not found.');
}
const filePath = path.join(__dirname, '../roles_backup.json');
if (!fs.existsSync(filePath)) {
return message.reply('No role backup file found.');
}
const rolesBackup = JSON.parse(fs.readFileSync(filePath, 'utf8'));
const rolesArray = rolesBackup[target.id];
await target.roles.remove(role);
if (rolesArray && rolesArray.length > 0) {
await target.roles.add(rolesArray);
message.channel.send(`${target.displayName} has been rewilded.`);
} else {
await target.roles.add(defaultRole);
message.channel.send(`${target.displayName} has returned to civilization.`);
}
delete rolesBackup[target.id];
fs.writeFileSync(filePath, JSON.stringify(rolesBackup, null, 2), 'utf8');
} catch (error) {
console.error('An error occurred:', error);
message.channel.send('There was an error trying to restore the roles.');
}
},
};