Skip to content

Commit

Permalink
lil cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmatthis committed Nov 28, 2024
1 parent ad1316d commit 8c9c121
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
15 changes: 13 additions & 2 deletions src/interfaces/discord/commands/discord-chat.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
import { DiscordMessageService } from '../services/discord-message.service';
import { DiscordOnMessageService } from '../services/discord-on-message.service';
import { DiscordThreadService } from '../services/discord-thread.service';
import { Message } from 'discord.js';

import { ActionRowBuilder, ButtonBuilder, Message } from 'discord.js';
import { ButtonStyle } from 'discord-api-types/v10';
export class StartingTextDto {
@StringOption({
name: 'text',
Expand Down Expand Up @@ -103,6 +103,17 @@ export class DiscordChatCommand {
);

const firstThreadMessage = firstThreadMessages[0];
await firstThreadMessage.edit({
content: firstThreadMessage.content,
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId('BUTTON')
.setLabel('LABEL')
.setStyle(ButtonStyle.Primary),
),
],
});

await this._onMessageService.addActiveChat(firstThreadMessage);
await this._messageService.respondToMessage(
Expand Down
30 changes: 17 additions & 13 deletions src/interfaces/discord/services/discord-thread.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,7 @@ export class DiscordThreadService {
if (threadName.length > maxThreadNameLength) {
threadName = threadName.substring(0, maxThreadNameLength);
}
const threadTitleEmbed = new EmbedBuilder()
.setColor(0x0099ff)
.setAuthor({
name: `Thread created by ${interaction.user.username}`,
iconURL: interaction.user.avatarURL(),
})
.setTimestamp()
.addFields({
name: '`skellybot` source code:',
value: 'https://github.com/freemocap/skellybot',
});
const anchorMessageEmbed = this._createAnchorMessageEmbed(interaction);

let threadAnchorMessage: Message;

Expand All @@ -31,14 +21,14 @@ export class DiscordThreadService {
content: `Thread Created for user: ${userMention(
interaction.user.id,
)}`,
embeds: [threadTitleEmbed],
embeds: [anchorMessageEmbed],
});
} else {
threadAnchorMessage = await interaction.channel.send({
content: `Thread Created for user: ${userMention(
interaction.user.id,
)}`,
embeds: [threadTitleEmbed],
embeds: [anchorMessageEmbed],
});
}

Expand All @@ -58,4 +48,18 @@ export class DiscordThreadService {
);
}
}

private _createAnchorMessageEmbed(interaction) {
return new EmbedBuilder()
.setColor(0x0099ff)
.setAuthor({
name: `Thread created by ${interaction.user.username}`,
iconURL: interaction.user.avatarURL(),
})
.setTimestamp()
.addFields({
name: '`skellybot` source code:',
value: 'https://github.com/freemocap/skellybot',
});
}
}

0 comments on commit 8c9c121

Please sign in to comment.