aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-07 20:15:45 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-07 20:15:45 -0400
commit35d03eb54fe81c1d5c0359db67455b82f754e3f4 (patch)
tree5666ac26f6fee5e06c2c3a523fced614cb6723bf
parent198aeadfc73642498afcb1eb637e0de86ccc9308 (diff)
downloadtanzanite-35d03eb54fe81c1d5c0359db67455b82f754e3f4.tar.gz
tanzanite-35d03eb54fe81c1d5c0359db67455b82f754e3f4.tar.bz2
tanzanite-35d03eb54fe81c1d5c0359db67455b82f754e3f4.zip
add owner bypasses and prevent blacklisted users from having their dms logged
-rw-r--r--src/commands/admin/roleAll.ts2
-rw-r--r--src/commands/config/config.ts2
-rw-r--r--src/commands/moderation/ban.ts4
-rw-r--r--src/commands/moderation/kick.ts2
-rw-r--r--src/commands/moderation/mute.ts2
-rw-r--r--src/commands/moderation/role.ts8
-rw-r--r--src/commands/moderation/unmute.ts2
-rw-r--r--src/commands/moderation/warn.ts2
-rw-r--r--src/commands/moulberry-bush/giveawayPing.ts4
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts2
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts16
-rw-r--r--src/listeners/message/directMessage.ts1
12 files changed, 27 insertions, 20 deletions
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts
index 82d15f5..ca82ca8 100644
--- a/src/commands/admin/roleAll.ts
+++ b/src/commands/admin/roleAll.ts
@@ -36,7 +36,7 @@ export default class RoleAllCommand extends BushCommand {
public override async exec(message: BushMessage, args: { role: Role; bot?: boolean }): Promise<unknown> {
if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`);
- if (!message.member!.permissions.has('ADMINISTRATOR'))
+ if (!message.member!.permissions.has('ADMINISTRATOR') && !message.member!.user.isOwner())
return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`);
if (args.role.comparePositionTo(message.guild.me!.roles.highest) >= 0 && !args.role) {
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index ac3198b..6e7373c 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -190,7 +190,7 @@ export default class SettingsCommand extends BushCommand {
}
): Promise<unknown> {
if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`);
- if (!message.member?.permissions.has('MANAGE_GUILD'))
+ if (!message.member?.permissions.has('MANAGE_GUILD') && !message.member?.user.isOwner())
return await message.util.reply(
`${util.emojis.error} You must have the **MANAGE_GUILD** permission to run this command.`
);
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 812d7ca..fea5543 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -122,14 +122,14 @@ export default class BanCommand extends BushCommand {
const responseCode = member
? await member.bushBan({
reason: parsedReason,
- moderator: message.author,
+ moderator: message.member,
duration: time! ?? 0,
deleteDays: days ?? 0
})
: await message.guild.bushBan({
user,
reason: parsedReason,
- moderator: message.author,
+ moderator: message.member,
duration: time! ?? 0,
deleteDays: days ?? 0
});
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index e7f9708..07c25ab 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -75,7 +75,7 @@ export default class KickCommand extends BushCommand {
const responseCode = await member.bushKick({
reason,
- moderator: message.author
+ moderator: message.member
});
const responseMessage = () => {
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 849873e..fba548b 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -86,7 +86,7 @@ export default class MuteCommand extends BushCommand {
const responseCode = await member.mute({
reason: parsedReason,
- moderator: message.author,
+ moderator: message.member,
duration: time! ?? 0
});
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index 15af014..d0abb54 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -97,7 +97,11 @@ export default class RoleCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
{ action, user, role, duration }: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole; duration?: number }
): Promise<unknown> {
- if (!message.member!.permissions.has('MANAGE_ROLES')) {
+ if (
+ !message.member!.permissions.has('MANAGE_ROLES') &&
+ message.member!.id !== message.guild?.ownerId &&
+ !message.member!.user.isOwner()
+ ) {
const mappings = client.consts.mappings;
let mappedRole: { name: string; id: string };
for (let i = 0; i < mappings.roleMap.length; i++) {
@@ -134,8 +138,6 @@ export default class RoleCommand extends BushCommand {
const responseMessage = () => {
switch (responseCode) {
case 'user hierarchy':
- client.console.debug(role.position);
- client.console.debug(user.roles.highest.position);
return `${util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`;
case 'role managed':
return `${util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`;
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 3383583..ee4bebe 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -77,7 +77,7 @@ export default class UnmuteCommand extends BushCommand {
const responseCode = await member.unmute({
reason,
- moderator: message.author
+ moderator: message.member
});
const responseMessage = async () => {
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 0fa83f3..44f4f5a 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -71,7 +71,7 @@ export default class WarnCommand extends BushCommand {
const { result: response, caseNum } = await member.warn({
reason,
- moderator: message.author
+ moderator: message.member
});
switch (response) {
diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts
index 4caaf0c..4b96e07 100644
--- a/src/commands/moulberry-bush/giveawayPing.ts
+++ b/src/commands/moulberry-bush/giveawayPing.ts
@@ -24,8 +24,8 @@ export default class GiveawayPingCommand extends BushCommand {
}
public override async exec(message: BushMessage): Promise<unknown> {
- if (!message.member!.permissions.has('MANAGE_GUILD'))
- await message.util.reply(`${util.emojis.error} You are missing the \`manage server\` permission.`);
+ if (!message.member!.permissions.has('MANAGE_GUILD') && !message.member!.user.isOwner())
+ await message.util.reply(`${util.emojis.error} You are missing the **MANAGE_GUILD** permission.`);
await message.delete().catch(() => {});
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index a1966e2..fbf3b5d 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -309,7 +309,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
this.commandHandler.useListenerHandler(this.listenerHandler);
this.commandHandler.useInhibitorHandler(this.inhibitorHandler);
this.commandHandler.ignorePermissions = this.config.owners;
- this.commandHandler.ignoreCooldown = this.config.owners.concat(this.cache.global.superUsers);
+ this.commandHandler.ignoreCooldown = [...new Set([...this.config.owners, ...this.cache.global.superUsers])];
this.listenerHandler.setEmitters({
client: this,
commandHandler: this.commandHandler,
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts
index 5575303..b5bc407 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/BushGuildMember.ts
@@ -1,14 +1,14 @@
import { GuildMember, MessageEmbed, Partialize, Role } from 'discord.js';
import { RawGuildMemberData } from 'discord.js/typings/rawDataTypes';
import { ModLogType } from '../../models/ModLog';
-import { BushClient, BushUserResolvable } from '../discord-akairo/BushClient';
+import { BushClient } from '../discord-akairo/BushClient';
import { BushGuild } from './BushGuild';
import { BushRole } from './BushRole';
import { BushUser } from './BushUser';
interface BushPunishmentOptions {
reason?: string | null;
- moderator?: BushUserResolvable;
+ moderator?: BushGuildMember;
}
interface BushTimedPunishmentOptions extends BushPunishmentOptions {
@@ -137,7 +137,7 @@ export class BushGuildMember extends GuildMember {
}
public async addRole(options: AddRoleOptions): Promise<AddRoleResponse> {
- const ifShouldAddRole = this.#checkIfShouldAddRole(options.role);
+ const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator);
if (ifShouldAddRole !== true) return ifShouldAddRole;
let caseID: string | undefined = undefined;
@@ -190,7 +190,7 @@ export class BushGuildMember extends GuildMember {
}
public async removeRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse> {
- const ifShouldAddRole = this.#checkIfShouldAddRole(options.role);
+ const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator);
if (ifShouldAddRole !== true) return ifShouldAddRole;
let caseID: string | undefined = undefined;
@@ -240,8 +240,12 @@ export class BushGuildMember extends GuildMember {
return ret;
}
- #checkIfShouldAddRole(role: BushRole | Role): true | 'user hierarchy' | 'role managed' | 'client hierarchy' {
- if (this.roles.highest.position <= role.position && this.guild.ownerId !== this.id) {
+ #checkIfShouldAddRole(
+ role: BushRole | Role,
+ moderator?: BushGuildMember
+ ): true | 'user hierarchy' | 'role managed' | 'client hierarchy' {
+ if (moderator && moderator.roles.highest.position <= role.position /* && this.guild.ownerId !== this.id */) {
+ client.console.debug(`${this.roles.highest.position} <= ${role.position}`);
return 'user hierarchy';
} else if (role.managed) {
return 'role managed';
diff --git a/src/listeners/message/directMessage.ts b/src/listeners/message/directMessage.ts
index 5da55ec..fd1533a 100644
--- a/src/listeners/message/directMessage.ts
+++ b/src/listeners/message/directMessage.ts
@@ -14,6 +14,7 @@ export default class DirectMessageListener extends BushListener {
public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<void> {
if (message.channel.type === 'DM') {
if (!(message.author.id == client.user!.id) && message.author.bot) return;
+ if (client.cache.global.blacklistedUsers.includes(message.author.id)) return;
const dmLogEmbed = new MessageEmbed().setTimestamp().setFooter(`User ID • ${message.channel.recipient.id}`);
if (message.author.id != client.user!.id) {