-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
37 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import BasePrefixCommand, { CommandData } from '#main/core/BasePrefixCommand.js'; | ||
import { Message } from 'discord.js'; | ||
|
||
export default class BlacklistPrefixCommand extends BasePrefixCommand { | ||
public readonly data: CommandData = { | ||
name: 'disconnect', | ||
description: 'Connect to a random chat group', | ||
category: 'Moderation', | ||
usage: 'connect', | ||
examples: ['disconnect', 'dc', 'hangup'], | ||
aliases: ['hangup', 'dc', 'disconn'], | ||
dbPermission: false, | ||
requiredArgs: 0, | ||
}; | ||
|
||
protected async run(message: Message<true>) { | ||
const { chatService } = message.client; | ||
const alreadyConnected = await chatService.getChannelGroup(message.channelId); | ||
if (!alreadyConnected) { | ||
await message.reply('This channel is not connected to a chat group!'); | ||
return; | ||
} | ||
|
||
await chatService.disconnectChannel(message.channelId); | ||
await message.reply('Disconnected from chat group!'); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,36 +1,50 @@ | ||
import { RegisterInteractionHandler } from '#main/decorators/RegisterInteractionHandler.js'; | ||
import { CustomID } from '#main/utils/CustomID.js'; | ||
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle } from 'discord.js'; | ||
import { handleError } from '#main/utils/Utils.js'; | ||
import { | ||
ActionRowBuilder, | ||
ButtonBuilder, | ||
ButtonInteraction, | ||
ButtonStyle, | ||
MessageActionRowComponentBuilder, | ||
} from 'discord.js'; | ||
|
||
export const markResolvedButton = () => | ||
new ActionRowBuilder<ButtonBuilder>().addComponents( | ||
new ButtonBuilder() | ||
.setCustomId(new CustomID().setIdentifier('markResolved').toString()) | ||
.setStyle(ButtonStyle.Success) | ||
.setLabel('Mark as Resolved'), | ||
); | ||
new ButtonBuilder() | ||
.setCustomId(new CustomID().setIdentifier('markResolved').toString()) | ||
.setStyle(ButtonStyle.Success) | ||
.setLabel('Mark Resolved'); | ||
|
||
export default class MarkResolvedButton { | ||
@RegisterInteractionHandler('markResolved') | ||
async handler(interaction: ButtonInteraction): Promise<void> { | ||
await interaction.deferUpdate(); | ||
const { components } = interaction.message; | ||
if (!components) return; | ||
try { | ||
await interaction.deferUpdate(); | ||
const components = interaction.message.components; | ||
if (!components) return; | ||
|
||
const rows = components.map((row) => new ActionRowBuilder(row)); | ||
const rows = components.map( | ||
(row) => ActionRowBuilder.from(row), | ||
) as ActionRowBuilder<MessageActionRowComponentBuilder>[]; | ||
|
||
rows.forEach((row) => { | ||
row.components.forEach((component) => { | ||
if ( | ||
component instanceof ButtonBuilder && | ||
component.data.style === ButtonStyle.Success && | ||
component.data.custom_id === interaction.customId | ||
) { | ||
component.setDisabled(true); | ||
} | ||
rows.forEach((row) => { | ||
row.components.forEach((component) => { | ||
if ( | ||
component instanceof ButtonBuilder && | ||
component.data.style === ButtonStyle.Success && | ||
component.data.custom_id === interaction.customId | ||
) { | ||
component.setLabel(`Resolved by @${interaction.user.username}`); | ||
component.setDisabled(true); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
await interaction.editReply({ components }); | ||
await interaction.editReply({ components: rows }); | ||
} | ||
catch (e) { | ||
e.message = `Failed to mark the message as resolved: ${e.message}`; | ||
handleError(e, interaction); | ||
} | ||
} | ||
} |
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