Skip to content

Commit

Permalink
fixed bugs in setnickname and toggletype, updated settings command an…
Browse files Browse the repository at this point in the history
…d setting category names, added userUpdate event and guildMemberUpdate event, added nickname, role add, and role remove logs, added log channels to the settings table, added setrolelogchannel and setnicknamelogchannel commands, changed "leave" to "farewell" across the board, updated botinfo, aliases, yomomma, and explainpoints, updated node-os-utils package version
  • Loading branch information
sabattle committed Sep 1, 2020
1 parent 5f6f0c5 commit c8dac30
Show file tree
Hide file tree
Showing 44 changed files with 433 additions and 306 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</a>

<a href="https://github.com/discordjs">
<img src="https://img.shields.io/badge/discord.js-v12.2.0-blue.svg?logo=npm" alt="shield.png">
<img src="https://img.shields.io/badge/discord.js-v12.3.1-blue.svg?logo=npm" alt="shield.png">
</a>

<a href="https://github.com/sabattle/CalypsoBot/blob/develop/LICENSE">
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"ascii-table": "0.0.9",
"better-sqlite3": "^7.1.0",
"common-tags": "^1.8.0",
"discord.js": "^12.2.0",
"discord.js": "^12.3.1",
"he": "^1.2.0",
"minimist": ">=1.2.2",
"moment": "^2.22.2",
"ms": "^2.1.2",
"node-os-utils": "^1.3.0",
"node-os-utils": "^1.3.1",
"node-pre-gyp": "^0.11.0",
"node-schedule": "^1.3.2",
"winston": "^3.2.1",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/admin/setadminrole.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = class SetAdminRoleCommand extends Command {
const oldAdminRole = message.guild.roles.cache.find(r => r.id === adminRoleId) || '`None`';

const embed = new MessageEmbed()
.setTitle('Settings: `Admin Role`')
.setTitle('Settings: `System`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`admin role\` was successfully updated. ${success}`)
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
Expand All @@ -29,13 +29,13 @@ module.exports = class SetAdminRoleCommand extends Command {
// Clear if no args provided
if (args.length === 0) {
message.client.db.settings.updateAdminRoleId.run(null, message.guild.id);
return message.channel.send(embed.addField('Role', `${oldAdminRole} ➔ \`None\``));
return message.channel.send(embed.addField('Admin Role', `${oldAdminRole} ➔ \`None\``));
}

// Update role
const adminRole = this.getRoleFromMention(message, args[0]) || message.guild.roles.cache.get(args[0]);
if (!adminRole) return this.sendErrorMessage(message, 0, 'Please mention a role or provide a valid role ID');
message.client.db.settings.updateAdminRoleId.run(adminRole.id, message.guild.id);
message.channel.send(embed.addField('Role', `${oldAdminRole}${adminRole}`));
message.channel.send(embed.addField('Admin Role', `${oldAdminRole}${adminRole}`));
}
};
6 changes: 3 additions & 3 deletions src/commands/admin/setautokick.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = class SetAutoKickCommand extends Command {
return this.sendErrorMessage(message, 0, 'Please enter a positive integer');

const embed = new MessageEmbed()
.setTitle('Settings: `Auto Kick`')
.setTitle('Settings: `System`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`\`Auto kick\` was successfully updated. ${success}`)
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
Expand All @@ -36,10 +36,10 @@ module.exports = class SetAutoKickCommand extends Command {
// Clear if no args provided
if (args.length === 0 || amount == 0) {
message.client.db.settings.updateAutoKick.run(null, message.guild.id);
return message.channel.send(embed.addField('Status', `\`${autoKick}\` ➔ \`disabled\``));
return message.channel.send(embed.addField('Auto Kick', `\`${autoKick}\` ➔ \`disabled\``));
}

message.client.db.settings.updateAutoKick.run(amount, message.guild.id);
message.channel.send(embed.addField('Status', `\`${autoKick}\` ➔ \`${amount}\``));
message.channel.send(embed.addField('Auto Kick', `\`${autoKick}\` ➔ \`${amount}\``));
}
};
6 changes: 3 additions & 3 deletions src/commands/admin/setautorole.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = class SetAutoRoleCommand extends Command {
const oldAutoRole = message.guild.roles.cache.find(r => r.id === autoRoleId) || '`None`';

const embed = new MessageEmbed()
.setTitle('Settings: `Auto Role`')
.setTitle('Settings: `System`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`auto role\` was successfully updated. ${success}`)
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
Expand All @@ -33,13 +33,13 @@ module.exports = class SetAutoRoleCommand extends Command {
// Clear if no args provided
if (args.length === 0) {
message.client.db.settings.updateAutoRoleId.run(null, message.guild.id);
return message.channel.send(embed.addField('Role', `${oldAutoRole} ➔ \`None\``));
return message.channel.send(embed.addField('Auto Role', `${oldAutoRole} ➔ \`None\``));
}

// Update role
const autoRole = this.getRoleFromMention(message, args[0]) || message.guild.roles.cache.get(args[0]);
if (!autoRole) return this.sendErrorMessage(message, 0, 'Please mention a role or provide a valid role ID');
message.client.db.settings.updateAutoRoleId.run(autoRole.id, message.guild.id);
message.channel.send(embed.addField('Role', `${oldAutoRole}${autoRole}`));
message.channel.send(embed.addField('Auto Role', `${oldAutoRole}${autoRole}`));
}
};
2 changes: 1 addition & 1 deletion src/commands/admin/setcommandpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = class SetCommandPointsCommand extends Command {
const status = message.client.utils.getStatus(pointTracking);
message.client.db.settings.updateCommandPoints.run(amount, message.guild.id);
const embed = new MessageEmbed()
.setTitle('Settings: `Points System`')
.setTitle('Settings: `Points`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`command points\` value was successfully updated. ${success}`)
.addField('Message Points', `\`${messagePoints}\``, true)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/setcrownchannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = class SetCrownChannelCommand extends Command {
if (crownMessage && crownMessage.length > 1024) crownMessage = crownMessage.slice(0, 1021) + '...';

const embed = new MessageEmbed()
.setTitle('Settings: `Crown System`')
.setTitle('Settings: `Crown`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`crown role\` was successfully updated. ${success}`)
.addField('Role', crownRole || '`None`', true)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/setcrownmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = class SetCrownMessageCommand extends Command {
const status = message.client.utils.getStatus(crownRoleId, crownSchedule);

const embed = new MessageEmbed()
.setTitle('Settings: `Crown System`')
.setTitle('Settings: `Crown`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`crown message\` was successfully updated. ${success}`)
.addField('Role', crownRole || '`None`', true)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/setcrownrole.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = class SetCrownRoleCommand extends Command {
if (crownMessage && crownMessage.length > 1024) crownMessage = crownMessage.slice(0, 1021) + '...';

const embed = new MessageEmbed()
.setTitle('Settings: `Crown System`')
.setTitle('Settings: `Crown`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`crown role\` was successfully updated. ${success}`)
.addField('Channel', crownChannel || '`None`', true)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/setcrownschedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = class SetCrownScheduleCommand extends Command {

let description = `The \`crown schedule\` was successfully updated. ${success}`;
const embed = new MessageEmbed()
.setTitle('Settings: `Crown System`')
.setTitle('Settings: `Crown`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(description)
.addField('Role', crownRole || '`None`', true)
Expand Down
72 changes: 72 additions & 0 deletions src/commands/admin/setfarewellchannel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const Command = require('../Command.js');
const { MessageEmbed } = require('discord.js');
const { success } = require('../../utils/emojis.json');
const { oneLine, stripIndent } = require('common-tags');

module.exports = class SetFarewellChannelCommand extends Command {
constructor(client) {
super(client, {
name: 'setfarewellchannel',
aliases: ['setlc', 'slc'],
usage: 'setfarewellchannel <channel mention/ID>',
description: oneLine`
Sets the farewell message text channel for your server.
Provide no channel to clear the current \`farewell channel\`.
A \`farewell message\` must also be set to enable farewell messages.
`,
type: client.types.ADMIN,
userPermissions: ['MANAGE_GUILD'],
examples: ['setfarewellchannel #general']
});
}
run(message, args) {
let { farewell_channel_id: farewellChannelId, farewell_message: farewellMessage } =
message.client.db.settings.selectFarewells.get(message.guild.id);
const oldFarewellChannel = message.guild.channels.cache.get(farewellChannelId) || '`None`';

// Get status
const oldStatus = message.client.utils.getStatus(farewellChannelId, farewellMessage);

// Trim message
if (farewellMessage && farewellMessage.length > 1024) farewellMessage = farewellMessage.slice(0, 1021) + '...';

const embed = new MessageEmbed()
.setTitle('Settings: `Farewells`')
.setDescription(`The \`farewell channel\` was successfully updated. ${success}`)
.addField('Message', message.client.utils.replaceKeywords(farewellMessage) || '`None`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor(message.guild.me.displayHexColor);

// Clear if no args provided
if (args.length === 0) {
message.client.db.settings.updateFarewellChannelId.run(null, message.guild.id);

// Update status
const status = 'disabled';
const statusUpdate = (oldStatus != status) ? `\`${oldStatus}\` ➔ \`${status}\`` : `\`${oldStatus}\``;

return message.channel.send(embed
.spliceFields(0, 0, { name: 'Channel', value: `${oldFarewellChannel} ➔ \`None\``, inline: true })
.spliceFields(1, 0, { name: 'Status', value: statusUpdate, inline: true })
);
}

const farewellChannel = this.getChannelFromMention(message, args[0]) || message.guild.channels.cache.get(args[0]);
if (!farewellChannel || (farewellChannel.type != 'text' && farewellChannel.type != 'news') || !farewellChannel.viewable)
return this.sendErrorMessage(message, 0, stripIndent`
Please mention an accessible text or announcement channel or provide a valid text or announcement channel ID
`);

// Update status
const status = message.client.utils.getStatus(farewellChannel, farewellMessage);
const statusUpdate = (oldStatus != status) ? `\`${oldStatus}\` ➔ \`${status}\`` : `\`${oldStatus}\``;

message.client.db.settings.updateFarewellChannelId.run(farewellChannel.id, message.guild.id);
message.channel.send(embed
.spliceFields(0, 0, { name: 'Channel', value: `${oldFarewellChannel}${farewellChannel}`, inline: true})
.spliceFields(1, 0, { name: 'Status', value: statusUpdate, inline: true})
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,46 @@ const { MessageEmbed } = require('discord.js');
const { success } = require('../../utils/emojis.json');
const { oneLine } = require('common-tags');

module.exports = class SetLeaveMessageCommand extends Command {
module.exports = class SetFarewellMessageCommand extends Command {
constructor(client) {
super(client, {
name: 'setleavemessage',
name: 'setfarewellmessage',
aliases: ['setlm', 'slm'],
usage: 'setleavemessage <message>',
usage: 'setfarewellmessage <message>',
description: oneLine`
Sets the message Calypso will say when someone leaves your server.
You may use \`?member\` to substitute for a user mention,
\`?username\` to substitute for someone's username,
\`?tag\` to substitute for someone's full Discord tag (username + discriminator),
and \`?size\` to substitute for your server's current member count.
Enter no message to clear the current \`leave message\`.
A \`leave channel\` must also be set to enable leave messages.
Enter no message to clear the current \`farewell message\`.
A \`farewell channel\` must also be set to enable farewell messages.
`,
type: client.types.ADMIN,
userPermissions: ['MANAGE_GUILD'],
examples: ['setleavemessage ?member has left the server.']
examples: ['setfarewellmessage ?member has left the server.']
});
}
run(message, args) {

const { leave_channel_id: leaveChannelId, leave_message: oldLeaveMessage } =
message.client.db.settings.selectLeaveMessages.get(message.guild.id);
const leaveChannel = message.guild.channels.cache.get(leaveChannelId);
const { farewell_channel_id: farewellChannelId, farewell_message: oldFarewellMessage } =
message.client.db.settings.selectFarewells.get(message.guild.id);
const farewellChannel = message.guild.channels.cache.get(farewellChannelId);

// Get status
const oldStatus = message.client.utils.getStatus(leaveChannelId, oldLeaveMessage);
const oldStatus = message.client.utils.getStatus(farewellChannelId, oldFarewellMessage);

const embed = new MessageEmbed()
.setTitle('Settings: `Leave Messages`')
.setTitle('Settings: `Farewells`')
.setThumbnail(message.guild.iconURL({ dynamic: true }))
.setDescription(`The \`leave message\` was successfully updated. ${success}`)
.addField('Channel', leaveChannel || '`None`', true)
.setDescription(`The \`farewell message\` was successfully updated. ${success}`)
.addField('Channel', farewellChannel || '`None`', true)
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor(message.guild.me.displayHexColor);

if (!args[0]) {
message.client.db.settings.updateLeaveMessage.run(null, message.guild.id);
message.client.db.settings.updateFarewellMessage.run(null, message.guild.id);

// Update status
const status = 'disabled';
Expand All @@ -54,17 +54,17 @@ module.exports = class SetLeaveMessageCommand extends Command {
);
}

let leaveMessage = message.content.slice(message.content.indexOf(args[0]), message.content.length);
message.client.db.settings.updateLeaveMessage.run(leaveMessage, message.guild.id);
if (leaveMessage.length > 1024) leaveMessage = leaveMessage.slice(0, 1021) + '...';
let farewellMessage = message.content.slice(message.content.indexOf(args[0]), message.content.length);
message.client.db.settings.updateFarewellMessage.run(farewellMessage, message.guild.id);
if (farewellMessage.length > 1024) farewellMessage = farewellMessage.slice(0, 1021) + '...';

// Update status
const status = message.client.utils.getStatus(leaveChannel, leaveMessage);
const status = message.client.utils.getStatus(farewellChannel, farewellMessage);
const statusUpdate = (oldStatus != status) ? `\`${oldStatus}\` ➔ \`${status}\`` : `\`${oldStatus}\``;

message.channel.send(embed
.addField('Status', statusUpdate, true)
.addField('Message', message.client.utils.replaceKeywords(leaveMessage))
.addField('Message', message.client.utils.replaceKeywords(farewellMessage))
);
}
};
Loading

0 comments on commit c8dac30

Please sign in to comment.