Skip to content

Commit

Permalink
get around invite link automod limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssa committed Jan 1, 2025
1 parent 645544e commit b825982
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export default {
"598555595808702473", // #beta-testing
],

allowedInvites: [
"PczBt78", // pluralkit
"2tFRMBw", // plural hub
"k5Psmjv7hy", // simply plural
],

// 2 weeks
newAccountDuration:
60 // seconds
Expand Down
31 changes: 31 additions & 0 deletions src/evt/autoModerationActionExecution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Context } from '..';
import config from '../config';

let sorryMessage = (id: string) => `<@${id}>
sorry, discord's automoderation feature doesn't let us allow specific invite links.
below is a copy of your message that included an allowed invite link (you can delete with ❌reaction).
sorry, this isn't able to repost images yet
`;

export default async (evt: any, ctx: Context) => {
if (evt.action.type != 3) return;
let split = evt.matched_content.split("/");
let invite = split[split.length - 1];
if (config.allowedInvites.includes(invite)) {
await ctx.rest.request({
body: { communication_disabled_until: null },
headers: { 'x-audit-log-reason': 'this invite link is allowed' },
route: {
method: 'PATCH',
path: '/guilds/:guildId/members/:userId',
params: { guildId: evt.guild_id, userId: evt.user_id, },
}
});
let sentMessage = await ctx.rest.createMessage(evt.channel_id, {
content: sorryMessage(evt.user_id),
embeds: [{ description: evt.content }],
});
await ctx.db.level.put(`replymsg:${sentMessage.id}`, evt.user_id);
await ctx.rest.createMessage("847022163982548992", "^ the above message contained an allowed invite link and was reposted");
}
}
4 changes: 3 additions & 1 deletion src/evt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import GUILD_MEMBER_UPDATE from "./guildMemberUpdate";
import GUILD_MEMBER_ADD from "./guildMemberAdd";
import MESSAGE_REACTION_ADD from './reactionAdd';
import MESSAGE_REACTION_REMOVE from './reactionRemove';
import AUTO_MODERATION_ACTION_EXECUTION from './autoModerationActionExecution';

export default {
MESSAGE_CREATE,
GUILD_MEMBER_ADD,
GUILD_MEMBER_UPDATE,
MESSAGE_REACTION_ADD,
MESSAGE_REACTION_REMOVE
MESSAGE_REACTION_REMOVE,
AUTO_MODERATION_ACTION_EXECUTION,
};
7 changes: 7 additions & 0 deletions src/evt/reactionAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { Context } from "..";
import roles from '../react_roles';

export default async (evt: any, ctx: Context) => {
if (evt.emoji.name == "❌") {
let replymsg = await ctx.db.level.get(`replymsg:${evt.message_id}`);
if (replymsg == evt.user_id) {
await ctx.rest.deleteMessage(evt.channel_id, evt.message_id);
}
}

const rr = roles[evt.message_id as string];
if (!rr) return;

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const token: string = process.env.token!;

const rest = new RestClient(token);
const socket = new SocketClient(token, {
intents: 5635,
// intents: 5635,
intents: 2102787,
presence: { activity: { type: 2, name: "vocaloid songs" } }
});
const level = new Level<string[]>('bot.db')
Expand Down

0 comments on commit b825982

Please sign in to comment.