Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
fix #16 一部Bot情報が取得できない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yogarasu committed Aug 23, 2022
1 parent ccbe279 commit 1053867
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion libs/user2.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PrismaClient, User } from "@prisma/client"
import { access, readFile, constants } from "node:fs/promises"
import { v4 as uuidv4 } from "uuid"
import type { Guild as DiscordClient } from "discord.js"
import { WebClient as SlackClient } from "@slack/web-api"
import { ChannelClient } from "./channel2.mjs"
Expand Down Expand Up @@ -139,13 +140,35 @@ export class UserClient {
if (bot) return bot

const result = await slackClient.bots.info({ bot: botId })
if (result.bot?.app_id) {
if (
result.bot !== undefined &&
result.bot.app_id !== undefined &&
result.bot.name !== undefined &&
result.bot.icons?.image_72 !== undefined &&
result.bot.deleted !== undefined
) {
bot = await this.client.user.findFirst({
where: {
appId: result.bot.app_id,
type: 3,
},
})
if (bot) return bot

bot = {
id: uuidv4(),
appId: result.bot.app_id,
botId: botId,
name: result.bot.name,
type: 3,
color: parseInt("808080", 16),
email: null,
imageUrl: result.bot.icons.image_72,
isBot: true,
isDeleted: result.bot.deleted,
createdAt: new Date(),
updatedAt: new Date(),
}
}
return bot
}
Expand Down

0 comments on commit 1053867

Please sign in to comment.