-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add admincommand & restart bot when failed
- Loading branch information
Showing
4 changed files
with
39 additions
and
32 deletions.
There are no files selected for viewing
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
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,29 @@ | ||
import {ChatInputCommandInteraction, Client, Message, SlashCommandBuilder} from "discord.js"; | ||
import {MongoUtil} from "../util/mongoUtil.js"; | ||
import {getRecommendedProblem} from "./prob.js"; | ||
import {logger} from "../logger.js"; | ||
|
||
export default{ | ||
data: new SlashCommandBuilder() | ||
.setName('adminmessage') | ||
.setDescription('ADMIN COMMAND') | ||
.addStringOption(option => option.setName('message').setDescription('공지사항을 입력해주세요.').setRequired(true)), | ||
|
||
async execute(interaction: ChatInputCommandInteraction){ | ||
if(interaction.user.id !== process.env.ADMIN_ID){ | ||
await interaction.reply("권한이 없습니다.") | ||
return; | ||
}else{ | ||
const users = await MongoUtil.findAllUser(); | ||
for (let user of users) { | ||
try{ | ||
const targetUser = await interaction.client.users.fetch(user.discord_id); | ||
await targetUser.send(interaction.options.getString('message')!); | ||
}catch (error){ | ||
logger.error(error); | ||
} | ||
} | ||
await interaction.reply("메시지를 전송했습니다.") | ||
} | ||
} | ||
} |
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