From 4c82a8be24a8fac44527947e5542432f183b61ba Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 8 Mar 2020 11:52:07 +0900 Subject: [PATCH 1/3] upgrade typescript to 3.8 --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 348f14b..ada938f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6283,9 +6283,9 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "typescript": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz", - "integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "dev": true }, "umd": { diff --git a/package.json b/package.json index bf662c4..8cfbf50 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "gulp-sourcemaps": "^2.6.5", "gulp-typescript": "^5.0.1", "mocha": "^6.2.0", - "typescript": "^3.5.3", + "typescript": "^3.8.3", "vinyl-source-stream": "latest" } } From e62ebbcb1cd53c7152b19277c74054f628fbf4d7 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 8 Mar 2020 12:03:12 +0900 Subject: [PATCH 2/3] add way to disable upload to youtube --- ts/discord-controller/main.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ts/discord-controller/main.ts b/ts/discord-controller/main.ts index e5cd52f..fac0fee 100644 --- a/ts/discord-controller/main.ts +++ b/ts/discord-controller/main.ts @@ -100,9 +100,14 @@ class CommandError extends Error { clientSecret: tokens.google.secret, }); - const youtube = new youtube_v3.Youtube({ - auth: googleClient - }); + let youtube: youtube_v3.Youtube | null; + if (process.env["YOUTUBE_DISABLED"]) { + youtube = null; + } else { + youtube = new youtube_v3.Youtube({ + auth: googleClient + }); + } console.log(`google OK`); await client.login(tokens.discord); console.log(`login success!`); @@ -226,7 +231,7 @@ class CommandError extends Error { const data = await recorderController.stop(); const date = recorderController.startAt; - const uploadPromise: GaxiosPromise = youtube.videos.insert({ + const uploadPromise: GaxiosPromise|null = youtube?.videos?.insert({ stabilize: false, media: { mimeType: "video/webm", @@ -249,6 +254,8 @@ class CommandError extends Error { await message.reply("recorder successfully stopped!"); try { + if (uploadPromise == null) + throw new Error("upload is disabled"); const result = await uploadPromise; await message.reply(`record is uploaded to https://youtu.be/${result.data.id}`); From a024753e630a66ea00349fa36813cb88d0d6092a Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 8 Mar 2020 13:24:52 +0900 Subject: [PATCH 3/3] fix: This condition will always return 'false' since the types '"text"' and '"group"' have no overlap. --- ts/markdown/writer/snowflakes.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ts/markdown/writer/snowflakes.ts b/ts/markdown/writer/snowflakes.ts index 69c8358..e6c048c 100644 --- a/ts/markdown/writer/snowflakes.ts +++ b/ts/markdown/writer/snowflakes.ts @@ -1,7 +1,7 @@ import {CustomWriter} from "./CustomWriter"; import {DiscordSnowflakeToken} from "../Tokens"; import {escapeHtml} from "../util"; -import {GuildChannel, Message} from "discord.js"; +import {Message} from "discord.js"; import {Env} from "../env"; function wrapMentionSpan(content: string, colorInt?: number) { @@ -28,11 +28,11 @@ export const snowflake_user: CustomWriter = function snow const id = token.snowflake; let userViewName: string; - if (msg.channel.type === 'dm' || msg.channel.type === 'group') { + if (msg.channel.type === 'dm') { let user = msg.client.users.resolve(id); userViewName = user != null ? `@${user.username}` : token.content; } else { - const member = (msg.channel as GuildChannel).guild.members.resolve(id); + const member = msg.channel.guild.members.resolve(id); if (member) { if (member.nickname) userViewName = `@${member.nickname}`; else userViewName = `@${member.user.username}`; @@ -57,7 +57,7 @@ export const snowflake_role: CustomWriter = function snow const id = token.snowflake; let userViewName: string; let color: number | undefined = undefined; - if (msg.channel.type === 'dm' || msg.channel.type === 'group') { + if (msg.channel.type === 'dm') { userViewName = token.content; } else { const role = msg.guild.roles.resolve(id); @@ -74,7 +74,7 @@ export const snowflake_role: CustomWriter = function snow export const snowflake_emoji: CustomWriter = function snowflake_emoji(writer, token, env): void { const msg = getMsg(env); const id = token.snowflake; - if (msg.channel.type === 'dm' || msg.channel.type === 'group') token.content; + if (msg.channel.type === 'dm') token.content; const emoji = msg.guild.emojis.resolve(id); writer.append(emoji ? `:${emoji.name}:` : escapeHtml(token.content));