Skip to content

Commit 6f5660d

Browse files
authored
Merge branch 'main' into ci/deploy-with-docker
2 parents 222be71 + d0a845b commit 6f5660d

File tree

13 files changed

+612
-68
lines changed

13 files changed

+612
-68
lines changed

.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
DISCORD_TOKEN="" # Your bot token
22
CLIENT_ID="" # Your bot's application ID
3-
GUIDES_CHANNEL_ID="" # The ID of the channel where guides will be posted
3+
4+
SERVER_ID=
5+
MODERATORS_ROLE_IDS= # Comma separated list of role IDs that are Moderators(Mods, Admins, etc)
6+
7+
REPEL_LOG_CHANNEL_ID= # Channel ID where the bot will log repel actions
8+
GUIDES_CHANNEL_ID="" # The ID of the channel where guides will be posted

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"license": "MIT",
3434
"packageManager": "pnpm@10.17.1",
3535
"dependencies": {
36-
"@discordjs/core": "^2.2.2",
3736
"discord.js": "^14.22.1",
3837
"typescript": "^5.9.3",
3938
"web-features": "^3.3.0"

pnpm-lock.yaml

Lines changed: 3 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { docsCommands } from './docs/index.js';
22
import { guidesCommand } from './guides/index.js';
3+
import cacheMessages from './moderation/cache-messages.js';
4+
import { repelCommand } from './moderation/repel.js';
35
import { pingCommand } from './ping.js';
46
import { tipsCommands } from './tips/index.js';
57
import type { Command } from './types.js';
68

79
export const commands = new Map<string, Command>(
8-
[pingCommand, guidesCommand, docsCommands, tipsCommands].flat().map((cmd) => [cmd.data.name, cmd])
10+
[pingCommand, guidesCommand, docsCommands, tipsCommands, repelCommand, cacheMessages]
11+
.flat()
12+
.map((cmd) => [cmd.data.name, cmd])
913
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { ApplicationCommandOptionType, PermissionFlagsBits, PermissionsBitField } from 'discord.js';
2+
import { fetchAndCachePublicChannelsMessages } from '../../util/cache.js';
3+
import { createCommand } from '../../util/commands.js';
4+
5+
export default createCommand({
6+
data: {
7+
name: 'cache-messages',
8+
description: 'Cache messages in all text channels of the server',
9+
default_member_permissions: new PermissionsBitField(
10+
PermissionFlagsBits.ManageMessages
11+
).toJSON(),
12+
options: [
13+
{
14+
name: 'force',
15+
description: 'Force re-caching even if messages are already cached',
16+
type: ApplicationCommandOptionType.Boolean,
17+
required: false,
18+
},
19+
],
20+
},
21+
execute: async (interaction) => {
22+
await interaction.deferReply();
23+
if (!interaction.guild || !interaction.isChatInputCommand()) {
24+
await interaction.editReply('This command can only be used in a guild.');
25+
return;
26+
}
27+
28+
if (!interaction.memberPermissions?.has(PermissionFlagsBits.ManageMessages)) {
29+
await interaction.editReply('You do not have permission to use this command.');
30+
return;
31+
}
32+
33+
const guild = interaction.guild;
34+
const force = interaction.options.getBoolean('force') ?? false;
35+
36+
await interaction.editReply('Caching messages in all public text channels...');
37+
38+
const { cachedChannels, totalChannels, failedChannels } =
39+
await fetchAndCachePublicChannelsMessages(guild, force);
40+
41+
const failedMessage = failedChannels.length
42+
? `\nFailed to cache messages in the following channels: ${failedChannels.map((id) => `<#${id}>`).join(', ')}`
43+
: '';
44+
45+
await interaction.editReply(
46+
`Cached messages in ${cachedChannels} out of ${totalChannels} text channels.${failedMessage}`
47+
);
48+
},
49+
});

0 commit comments

Comments
 (0)