Skip to content

Commit

Permalink
🐛 /setupコマンドでverifiedロールが存在する場合にsetupコマンドを中止するように修正 (backend/src/comm…
Browse files Browse the repository at this point in the history
…ands/setup.ts)
  • Loading branch information
HidemaruOwO committed Jan 22, 2023
1 parent aea92bf commit e41e598
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions backend/src/commands/setup.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
import {
Client,
BaseCommandInteraction,
MessageButton,
MessageActionRow,
Client,
BaseCommandInteraction,
MessageButton,
MessageActionRow,
} from "discord.js";
import { Command } from "../interface";

const cmd: Command = {
data: {
name: "setup",
description: "Discord hCaptch認証のセットアップをします",
defaultMemberPermissions: ["ADMINISTRATOR"],
},
async execute(client: Client, interaction: BaseCommandInteraction) {
const guild = interaction.guild;
await interaction.reply({
content: "セットアップを開始します",
ephemeral: true,
});
const role = guild?.roles.cache.find((role) => role.name === "verified");
if (!role === undefined) {
data: {
name: "setup",
description: "Discord hCaptch認証のセットアップをします",
defaultMemberPermissions: ["ADMINISTRATOR"],
},
async execute(client: Client, interaction: BaseCommandInteraction) {
const guild = interaction.guild;
await interaction.reply({
content: "セットアップを開始します",
ephemeral: true,
});
const role = guild?.roles.cache.find((role) => role.name === "verified");
if (!role === void 0) {
await interaction.editReply({
content:
"Verifiedロールが存在します\n認証ボタンを作成する場合は`/genbutton`コマンドを実行してください",
});
return;
}
guild?.roles.create({ name: "verified" });
await interaction.editReply({
content:
"Verifiedロールが存在します\n認証ボタンを作成する場合は`/genbutton`コマンドを実行してください",
content: "ロールを作成しました",
});
const button = new MessageButton()
.setCustomId("verify")
.setStyle("PRIMARY")
.setLabel("認証")
.setEmoji("✅");
await interaction.channel?.send({
embeds: [
{
title: "認証方法",
description: "認証を行うには、以下のボタンを押してください",
color: "RANDOM",
timestamp: new Date(),
footer: {
text: "©️ HidemaruOwO | Discord hCaptcha",
},
},
],
components: [new MessageActionRow().addComponents(button)],
});
return;
}
guild?.roles.create({ name: "verified" });
await interaction.editReply({
content: "ロールを作成しました",
});
const button = new MessageButton()
.setCustomId("verify")
.setStyle("PRIMARY")
.setLabel("認証")
.setEmoji("✅");
await interaction.channel?.send({
embeds: [
{
title: "認証方法",
description: "認証を行うには、以下のボタンを押してください",
color: "RANDOM",
timestamp: new Date(),
footer: {
text: "©️ HidemaruOwO | Discord hCaptcha",
},
},
],
components: [new MessageActionRow().addComponents(button)],
});
await interaction.editReply({ content: "セットアップを完了しました" });
},
await interaction.editReply({ content: "セットアップを完了しました" });
},
};

export { cmd };

1 comment on commit e41e598

@HidemaruOwO
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2

Please sign in to comment.