File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { 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+ } ,
13+ execute : async ( interaction ) => {
14+ await interaction . deferReply ( ) ;
15+ if ( ! interaction . guild ) {
16+ await interaction . editReply ( 'This command can only be used in a guild.' ) ;
17+ return ;
18+ }
19+
20+ if ( ! interaction . memberPermissions ?. has ( PermissionFlagsBits . ManageMessages ) ) {
21+ await interaction . editReply ( 'You do not have permission to use this command.' ) ;
22+ return ;
23+ }
24+
25+ const guild = interaction . guild ;
26+
27+ await interaction . editReply ( 'Caching messages in all public text channels...' ) ;
28+
29+ const { cachedChannels, totalChannels } = await fetchAndCachePublicChannelsMessages ( guild ) ;
30+
31+ await interaction . editReply (
32+ `Cached messages in ${ cachedChannels } out of ${ totalChannels } text channels.`
33+ ) ;
34+
35+ return ;
36+ } ,
37+ } ) ;
You can’t perform that action at this time.
0 commit comments