Skip to content

Commit

Permalink
v10.11.1 (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtraction committed Jun 1, 2023
2 parents 7221baa + 52e8e8f commit 1601da6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bastion",
"version": "10.11.0",
"version": "10.11.1",
"description": "Get an enhanced Discord experience!",
"type": "module",
"homepage": "https://bastion.traction.one",
Expand Down
47 changes: 26 additions & 21 deletions src/commands/config/filter/invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author TRACTION (iamtraction)
* @copyright 2023
*/
import { AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js";
import { AutoModerationActionOptions, AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js";
import { Command, Logger } from "@bastion/tesseract";

import GuildModel from "../../../models/Guild.js";
Expand Down Expand Up @@ -35,6 +35,30 @@ class FilterInvitesCommand extends Command {
return await interaction.editReply(`I've ${ newInviteFilterRule.enabled ? "enabled" : "disabled" } the **${ newInviteFilterRule.name }** AutoMod rule.`);
}

const actions: AutoModerationActionOptions[] = [
{
type: AutoModerationActionType.BlockMessage,
metadata: {
customMessage: "You are not allowed to send invites in this channel.",
},
},
{
type: AutoModerationActionType.Timeout,
metadata: {
durationSeconds: 60,
},
},
];

if (interaction.guild.channels.cache.has(guildDocument.moderationLogChannel)) {
actions.push({
type: AutoModerationActionType.SendAlertMessage,
metadata: {
channel: guildDocument.moderationLogChannel,
},
});
}

// create invite filter rule
const newInviteFilterRule = await interaction.guild.autoModerationRules.create({
enabled: true,
Expand All @@ -46,26 +70,7 @@ class FilterInvitesCommand extends Command {
"(?:https?://)?(?:www\\.)?(?:discord\\.gg|discord(?:app)?\\.com/invite)/[a-z0-9-.]+",
],
},
actions: [
{
type: AutoModerationActionType.BlockMessage,
metadata: {
customMessage: "You are not allowed to send invites in this channel.",
},
},
{
type: AutoModerationActionType.SendAlertMessage,
metadata: {
channel: guildDocument.moderationLogChannel,
},
},
{
type: AutoModerationActionType.Timeout,
metadata: {
durationSeconds: 60,
},
},
],
actions,
reason: "Configure Invite Filter",
});

Expand Down
47 changes: 26 additions & 21 deletions src/commands/config/filter/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author TRACTION (iamtraction)
* @copyright 2023
*/
import { AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js";
import { AutoModerationActionOptions, AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js";
import { Command, Logger } from "@bastion/tesseract";

import GuildModel from "../../../models/Guild.js";
Expand Down Expand Up @@ -35,6 +35,30 @@ class FilterLinksCommand extends Command {
return await interaction.editReply(`I've ${ newLinkFilterRule.enabled ? "enabled" : "disabled" } the **${ newLinkFilterRule.name }** AutoMod rule.`);
}

const actions: AutoModerationActionOptions[] = [
{
type: AutoModerationActionType.BlockMessage,
metadata: {
customMessage: "You are not allowed to send links in this channel.",
},
},
{
type: AutoModerationActionType.Timeout,
metadata: {
durationSeconds: 60,
},
},
];

if (interaction.guild.channels.cache.has(guildDocument.moderationLogChannel)) {
actions.push({
type: AutoModerationActionType.SendAlertMessage,
metadata: {
channel: guildDocument.moderationLogChannel,
},
});
}

// create link filter rule
const newLinkFilterRule = await interaction.guild.autoModerationRules.create({
enabled: true,
Expand All @@ -46,26 +70,7 @@ class FilterLinksCommand extends Command {
"https?://(?:[-;:&=+$,\\w]+@)?[A-Za-z0-9.-]+",
],
},
actions: [
{
type: AutoModerationActionType.BlockMessage,
metadata: {
customMessage: "You are not allowed to send links in this channel.",
},
},
{
type: AutoModerationActionType.SendAlertMessage,
metadata: {
channel: guildDocument.moderationLogChannel,
},
},
{
type: AutoModerationActionType.Timeout,
metadata: {
durationSeconds: 60,
},
},
],
actions,
reason: "Configure Link Filter",
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author TRACTION (iamtraction)
* @copyright 2022
*/
export const SERVER_INVITE = /(https:\/\/)?(www\.)?(discord\.gg|discordapp\.com\/invite|discord\.com\/invite)\/([a-z0-9-.]+)?/i;
export const SERVER_INVITE = /(?:https?:\/\/)?(?:www\.)?(?:discord\.gg|discord(?:app)?\.com\/invite)\/([a-z0-9-.]+)/i;
export const URI = /((([A-Za-z]{3,9}:(?:\/\/))(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/i;
export const WEBHOOK_URL = /(?:https:\/\/)(?:www\.)?(?:discordapp|discord)\.com\/api\/webhooks\/([0-9]+)\/([a-z0-9_-]+)/i;

Expand Down

0 comments on commit 1601da6

Please sign in to comment.