-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update DJS and get ready for p4a 25
- Loading branch information
1 parent
a56f3e2
commit 16bdf2a
Showing
12 changed files
with
2,264 additions
and
1,695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"faxable", | ||
"ggsans", | ||
"GREYPLE", | ||
"ical", | ||
"manageroll", | ||
"managerolls", | ||
"monoselect", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ApplyOptions } from '@sapphire/decorators'; | ||
import { UserError, type Command, type CommandOptions } from '@sapphire/framework'; | ||
import { SteveCommand } from '@lib/extensions/SteveCommand'; | ||
import { ChannelType } from 'discord.js'; | ||
|
||
@ApplyOptions<CommandOptions>({ | ||
description: 'Condense a category into a summary channel', | ||
requiredUserPermissions: ['ManageChannels'] | ||
}) | ||
export class UserCommand extends SteveCommand { | ||
|
||
public override registerApplicationCommands(registry: Command.Registry) { | ||
registry.registerChatInputCommand(builder => { | ||
builder | ||
.setName(this.name) | ||
.setDescription(this.description) | ||
.addChannelOption(option => | ||
option | ||
.setName('category') | ||
.setDescription('The category to condense') | ||
.setRequired(true) | ||
.addChannelTypes(ChannelType.GuildCategory) | ||
); | ||
}, { guildIds: ['989658500563095562', '723241105323327578'] }); | ||
} | ||
|
||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { | ||
if (!interaction.guild) { | ||
throw new UserError({ | ||
identifier: 'condenseSummariesMissingGuild', | ||
message: 'This command must be run in a server.' | ||
}); | ||
} | ||
await interaction.deferReply({ ephemeral: true }); | ||
|
||
const category = interaction.options.getChannel<ChannelType.GuildCategory>('category', true); | ||
|
||
const summaryChannelPromise = interaction.guild.channels.create({ | ||
name: category.name, | ||
type: ChannelType.GuildText | ||
}); | ||
|
||
const messages: string[] = []; | ||
|
||
for (const channel of category.children.cache.sort((a, b) => a.position - b.position).values()) { | ||
if (channel.type === ChannelType.GuildText) { | ||
messages.push(`# ${channel.name | ||
.replace(/[-_]/g, ' ') | ||
.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase()) | ||
}`); | ||
|
||
await channel.messages.fetch().then(channelMessages => { | ||
messages.push(...channelMessages.map(message => message.content)); | ||
}); | ||
} | ||
}; | ||
|
||
const summaryChannel = await summaryChannelPromise; | ||
|
||
for (const message of messages) { | ||
await summaryChannel.send(message); | ||
} | ||
|
||
await interaction.editReply({ | ||
content: `Condensed ${category.name} into ${summaryChannel}` | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Precondition } from '@sapphire/framework'; | ||
import type { CommandInteraction, Message } from 'discord.js'; | ||
|
||
export class UserPrecondition extends Precondition { | ||
|
||
public async messageRun(message: Message) { | ||
return message.guildId === '989658500563095562' | ||
? this.ok() | ||
: this.error({ | ||
message: 'This command can only be run in the Deposits & Deductions Server' | ||
}); | ||
} | ||
|
||
public chatInputRun(interaction: CommandInteraction) { | ||
return interaction.guildId === '989658500563095562' | ||
? this.ok() | ||
: this.error({ | ||
message: 'This command can only be run in the Deposits & Deductions Server' | ||
}); | ||
} | ||
|
||
} | ||
|
||
declare module '@sapphire/framework' { | ||
interface Preconditions { | ||
DepositsAndDeductionsOnly: never; | ||
} | ||
} |
Oops, something went wrong.