Skip to content

Commit 1ae93fd

Browse files
committed
feat: delete system message when bot pins a message
1 parent a6c1c29 commit 1ae93fd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/events/messages.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { type Client, Events, MessageType } from "discord.js";
2+
3+
export default function registerEvents(client: Client) {
4+
return client.on(Events.MessageCreate, async (message) => {
5+
// If the bot pins a message, then we delete the automatic announcement message
6+
if(message.type === MessageType.ChannelPinnedMessage && message.author.id === client.user.id) {
7+
await message.delete();
8+
}
9+
});
10+
}

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { config } from "./lib/config.js";
22

33
import registerCommandEvents from "./events/commands.js";
44
import registerWalkthroughEvents from "./events/walkthrough.js";
5+
import registerMessageEvents from "./events/messages.js";
56

67
import { Client, Events, GatewayIntentBits, ActivityType } from "discord.js";
78

8-
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
9+
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
910

1011
const presenceList = [
1112
{ name: "with Coder", type: ActivityType.Playing },
@@ -33,6 +34,7 @@ client.once(Events.ClientReady, () => {
3334

3435
registerCommandEvents(client);
3536
registerWalkthroughEvents(client);
37+
registerMessageEvents(client);
3638

3739
shufflePresence();
3840
setInterval(shufflePresence, config.presenceDelay);

0 commit comments

Comments
 (0)