This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
forked from tainakanchu/mds-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #16 destroyコマンドでカラムを削除せずにdeployIDだけを削除するように修正
- Loading branch information
yogarasu
committed
Aug 22, 2022
1 parent
5424b23
commit 5667c20
Showing
8 changed files
with
203 additions
and
33 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
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,71 @@ | ||
import { Command } from "commander" | ||
import dotenv from "dotenv" | ||
import type { Guild as DiscordClient } from "discord.js" | ||
import prompts from "prompts" | ||
import { Spinner } from "../../libs/util/spinner.mjs" | ||
import { createDiscordClient } from "../../libs/client.mjs" | ||
import { MessageClient } from "../../libs/message2.mjs" | ||
|
||
dotenv.config({ path: "./.env" }) | ||
const spinner = new Spinner() | ||
|
||
interface Options { | ||
discordBotToken?: string | ||
discordServerId?: string | ||
} | ||
|
||
;(async () => { | ||
const confirm = await prompts({ | ||
type: "confirm", | ||
name: "value", | ||
message: "Destroy message?", | ||
}) | ||
if (!confirm.value) process.exit(0) | ||
|
||
const program = new Command() | ||
program | ||
.description("Destroy message command") | ||
.requiredOption( | ||
"-dt, --discord-bot-token [string]", | ||
"DiscordBot OAuth Token", | ||
process.env.DISCORD_BOT_TOKEN | ||
) | ||
.requiredOption( | ||
"-ds, --discord-server-id [string]", | ||
"Discord Server ID", | ||
process.env.DISCORD_SERVER_ID | ||
) | ||
.parse(process.argv) | ||
|
||
spinner.loading("Check parameter") | ||
const options: Options = program.opts() | ||
const { discordBotToken, discordServerId } = options | ||
if (discordBotToken === undefined || discordServerId === undefined) { | ||
spinner.failed(null, "Required parameter is not found") | ||
process.exit(1) | ||
} | ||
spinner.success() | ||
|
||
spinner.loading("Create client") | ||
let messageClient: MessageClient | undefined = undefined | ||
let discordClient: DiscordClient | null = null | ||
try { | ||
messageClient = new MessageClient() | ||
discordClient = await createDiscordClient(discordBotToken, discordServerId) | ||
} catch (error) { | ||
spinner.failed(null, error) | ||
process.exit(1) | ||
} | ||
spinner.success() | ||
|
||
spinner.loading("Destroy message") | ||
try { | ||
await messageClient.destroyAllMessage(discordClient) | ||
} catch (error) { | ||
spinner.failed(null, error) | ||
process.exit(1) | ||
} | ||
spinner.success() | ||
|
||
process.exit(0) | ||
})() |
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
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