Skip to content

Commit

Permalink
v10.11 (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtraction authored May 19, 2023
2 parents 9c6d7db + 2338938 commit 7221baa
Show file tree
Hide file tree
Showing 22 changed files with 243 additions and 276 deletions.
2 changes: 1 addition & 1 deletion commands.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bastion",
"version": "10.10.1",
"version": "10.11.0",
"description": "Get an enhanced Discord experience!",
"type": "module",
"homepage": "https://bastion.traction.one",
Expand All @@ -22,7 +22,7 @@
"@types/express": "^4.17.17",
"@types/http-errors": "^2.0.1",
"@types/jsdom": "^21.1.1",
"@types/node": "^18.15.11",
"@types/node": "^20.1.2",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"eslint": "^8.37.0",
Expand All @@ -37,7 +37,7 @@
"dotenv": "^16.0.3",
"emoji-regex": "^10.2.1",
"gamedig": "^4.0.6",
"jsdom": "^21.1.0",
"jsdom": "^22.0.0",
"libsodium-wrappers": "^0.7.11",
"mathjs": "^11.7.0",
"play-dl": "^1.9.6",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/farewell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FarewellCommand extends Command {
{
type: ApplicationCommandOptionType.String,
name: "message",
description: "The farewell message.",
description: "The custom farewell message.",
},
{
type: ApplicationCommandOptionType.Integer,
Expand Down
56 changes: 0 additions & 56 deletions src/commands/config/filter.ts

This file was deleted.

82 changes: 82 additions & 0 deletions src/commands/config/filter/invites.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*!
* @author TRACTION (iamtraction)
* @copyright 2023
*/
import { AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js";
import { Command, Logger } from "@bastion/tesseract";

import GuildModel from "../../../models/Guild.js";

class FilterInvitesCommand extends Command {
constructor() {
super({
name: "invites",
description: "Configure Invite Filter AutoMod rule in the server.",
userPermissions: [ PermissionFlagsBits.ManageGuild ],
clientPermissions: [ PermissionFlagsBits.ManageGuild ],
});
}

public async exec(interaction: ChatInputCommandInteraction<"cached">): Promise<unknown> {
await interaction.deferReply();

// get guild document
const guildDocument = await GuildModel.findById(interaction.guildId);

// get the invite filter rule if it exists
const inviteFilterRule = guildDocument.inviteFilterRule && await interaction.guild.autoModerationRules.fetch({
autoModerationRule: guildDocument.inviteFilterRule,
cache: false,
}).catch(Logger.ignore);

// toggle invite filter rule if it exists
if (inviteFilterRule) {
const newInviteFilterRule = await inviteFilterRule.setEnabled(!inviteFilterRule.enabled, `${ inviteFilterRule.enabled ? "Disable" : "Enable" } Invite Filter`);
return await interaction.editReply(`I've ${ newInviteFilterRule.enabled ? "enabled" : "disabled" } the **${ newInviteFilterRule.name }** AutoMod rule.`);
}

// create invite filter rule
const newInviteFilterRule = await interaction.guild.autoModerationRules.create({
enabled: true,
name: "Block Invites",
eventType: AutoModerationRuleEventType.MessageSend,
triggerType: AutoModerationRuleTriggerType.Keyword,
triggerMetadata: {
regexPatterns: [
"(?: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,
},
},
],
reason: "Configure Invite Filter",
});

// update invite filter rule id
guildDocument.inviteFilterRule = newInviteFilterRule.id;

// save document
await guildDocument.save();

return await interaction.editReply("I've configured the invite filter AutoMod rule.");
}
}

export { FilterInvitesCommand as Command };
82 changes: 82 additions & 0 deletions src/commands/config/filter/links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*!
* @author TRACTION (iamtraction)
* @copyright 2023
*/
import { AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js";
import { Command, Logger } from "@bastion/tesseract";

import GuildModel from "../../../models/Guild.js";

class FilterLinksCommand extends Command {
constructor() {
super({
name: "links",
description: "Configure Link Filter AutoMod rule in the server.",
userPermissions: [ PermissionFlagsBits.ManageGuild ],
clientPermissions: [ PermissionFlagsBits.ManageGuild ],
});
}

public async exec(interaction: ChatInputCommandInteraction<"cached">): Promise<unknown> {
await interaction.deferReply();

// get guild document
const guildDocument = await GuildModel.findById(interaction.guildId);

// get the link filter rule if it exists
const linkFilterRule = guildDocument.linkFilterRule && await interaction.guild.autoModerationRules.fetch({
autoModerationRule: guildDocument.linkFilterRule,
cache: false,
}).catch(Logger.ignore);

// toggle link filter rule if it exists
if (linkFilterRule) {
const newLinkFilterRule = await linkFilterRule.setEnabled(!linkFilterRule.enabled, `${ linkFilterRule.enabled ? "Disable" : "Enable" } Link Filter`);
return await interaction.editReply(`I've ${ newLinkFilterRule.enabled ? "enabled" : "disabled" } the **${ newLinkFilterRule.name }** AutoMod rule.`);
}

// create link filter rule
const newLinkFilterRule = await interaction.guild.autoModerationRules.create({
enabled: true,
name: "Block Links",
eventType: AutoModerationRuleEventType.MessageSend,
triggerType: AutoModerationRuleTriggerType.Keyword,
triggerMetadata: {
regexPatterns: [
"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,
},
},
],
reason: "Configure Link Filter",
});

// update link filter rule id
guildDocument.linkFilterRule = newLinkFilterRule.id;

// save document
await guildDocument.save();

return await interaction.editReply("I've configured the link filter AutoMod rule.");
}
}

export { FilterLinksCommand as Command };
2 changes: 1 addition & 1 deletion src/commands/config/gamification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GamificationCommand extends Command {
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where the level up messages should be sent.",
description: "The channel where the level up messages will be sent.",
channel_types: [ ChannelType.GuildText ],
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/greeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GreetingCommand extends Command {
{
type: ApplicationCommandOptionType.String,
name: "message",
description: "The greeting message.",
description: "The custom greeting message.",
},
{
type: ApplicationCommandOptionType.Integer,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/config/liveStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class LiveStreamsCommand extends Command {
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where you want to post the notification.",
description: "The channel where the notifications will be sent.",
channel_types: [ ChannelType.GuildText ],
},
{
type: ApplicationCommandOptionType.String,
name: "message",
description: "A custom message to show with the live notification.",
description: "The custom message for notification.",
},
],
userPermissions: [ PermissionFlagsBits.ManageGuild ],
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/logs/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LogModCommand extends Command {
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where moderation logs should be sent.",
description: "The channel where moderation events will be logged.",
channel_types: [ ChannelType.GuildText ],
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/logs/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LogServerCommand extends Command {
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where server logs should be sent.",
description: "The channel where server events will be logged.",
channel_types: [ ChannelType.GuildText ],
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/commands/config/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class ReportsCommand extends Command {
constructor() {
super({
name: "reports",
description: "Configure reports in the server.",
description: "Configure user reports in the server.",
options: [
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where reports should be sent.",
description: "The channel where user reports will be sent.",
channel_types: [ ChannelType.GuildText ],
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/starboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StarboardCommand extends Command {
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where starred messages should be sent.",
description: "The channel where starred messages will be logged.",
channel_types: [ ChannelType.GuildText ],
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SuggestionsCommand extends Command {
{
type: ApplicationCommandOptionType.Channel,
name: "channel",
description: "The channel where suggestions should be sent.",
description: "The channel where suggestions will be sent.",
channel_types: [ ChannelType.GuildText ],
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class VerificationCommand extends Command {
{
type: ApplicationCommandOptionType.Role,
name: "role",
description: "The role that should be assigned to verified users.",
description: "The role users are assigned when are verified.",
},
{
type: ApplicationCommandOptionType.String,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/user/infractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ class UserInfractionsCommand extends Command {
{
type: ApplicationCommandOptionType.Integer,
name: "timeout",
description: "Number of violations after which the user is timed out.",
description: "Number of violations after which a user is timed out.",
min_value: 1,
},
{
type: ApplicationCommandOptionType.Integer,
name: "kick",
description: "Number of violations after which the user is kicked.",
description: "Number of violations after which a user is kicked.",
min_value: 1,
},
{
type: ApplicationCommandOptionType.Integer,
name: "ban",
description: "Number of violations after which the user is banned.",
description: "Number of violations after which a user is banned.",
min_value: 1,
},
{
Expand Down
Loading

0 comments on commit 7221baa

Please sign in to comment.