-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: VoiceDiffを送信するチャンネルを指定する環境変数の追加 * change: CodeStylesの設定変更 * add: 継承の追加 * add: 継承のインポート * change: Genericsの追加 * add: Embedのモデルを追加 * add: VoiceDiff機能の追加 * add: エンドポイントへのVoiceDiff実装 * Update src/server/index.ts Co-authored-by: Mikuroさいな <ryosukadnak@gmail.com> * fix: VoiceRoomResponseRunnerが関数の外で破棄されてしまっている問題の修正 * Fix with StandardOutput * Remove log * Update lock * Remove .idea * change: .idea/ディレクトリの除外 * add: VoiceDiffのテストを追加 * rename: EmbedMessage -> embed-message * fix: 二重命名の修正 Co-authored-by: Mikuroさいな <ryosukadnak@gmail.com>
- Loading branch information
1 parent
20c154b
commit 8cc0fe0
Showing
22 changed files
with
208 additions
and
182 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
DISCORD_TOKEN= | ||
MAIN_CHANNEL_ID= |
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 |
---|---|---|
|
@@ -118,3 +118,6 @@ dist | |
|
||
# ts | ||
build/ | ||
|
||
# WebStorm | ||
.idea/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,53 @@ | ||
import { Client, MessageEmbed } from 'discord.js'; | ||
import type { EmbedMessage } from '../model/embed-message'; | ||
import type { StandardOutput } from '../service/voice-diff'; | ||
|
||
export class DiscordOutput implements StandardOutput { | ||
constructor( | ||
private readonly client: Client, | ||
private readonly channelId: string | ||
) {} | ||
|
||
async sendEmbed(embed: EmbedMessage): Promise<void> { | ||
const channel = await this.client.channels.fetch(this.channelId); | ||
if (!channel || !channel.isText()) { | ||
throw new Error(`the channel (${this.channelId}) is not text channel`); | ||
} | ||
|
||
const made = buildEmbed(embed); | ||
await channel.send({ | ||
embeds: [made] | ||
}); | ||
} | ||
} | ||
|
||
function buildEmbed(embed: EmbedMessage) { | ||
const makeEmbed = new MessageEmbed(); | ||
const { title, color, description, fields, url, footer, thumbnail, author } = | ||
embed; | ||
if (author) { | ||
makeEmbed.setAuthor({ name: author.name, iconURL: author.iconUrl }); | ||
} | ||
if (color) { | ||
makeEmbed.setColor(color); | ||
} | ||
if (description) { | ||
makeEmbed.setDescription(description); | ||
} | ||
if (fields) { | ||
makeEmbed.setFields(fields); | ||
} | ||
if (footer) { | ||
makeEmbed.setFooter({ text: footer }); | ||
} | ||
if (title) { | ||
makeEmbed.setTitle(title); | ||
} | ||
if (url) { | ||
makeEmbed.setURL(url); | ||
} | ||
if (thumbnail) { | ||
makeEmbed.setThumbnail(thumbnail.url); | ||
} | ||
return makeEmbed; | ||
} |
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,22 @@ | ||
import type { VoiceChannelParticipant } from '../service/voice-diff'; | ||
import type { VoiceState } from 'discord.js'; | ||
|
||
export class DiscordParticipant implements VoiceChannelParticipant { | ||
constructor(private voiceState: VoiceState) {} | ||
|
||
get userName(): string { | ||
return this.voiceState.member?.displayName ?? '名無し'; | ||
} | ||
|
||
get userAvatar(): string { | ||
const avatarURL = this.voiceState.member?.displayAvatarURL(); | ||
if (!avatarURL) { | ||
throw new Error('アバターが取得できませんでした。'); | ||
} | ||
return avatarURL; | ||
} | ||
|
||
get channelName(): string { | ||
return this.voiceState.channel?.name ?? '名無し'; | ||
} | ||
} |
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
Oops, something went wrong.