실시간 콘솔 명령어로 디스코드 봇 원격 관리하기

Q&A 아카이브2026년 7월 15일·메시지 6개

원본 디스코드 대화 기록 (6개 메시지)

질문자05. 05. PM 09:45

추후 실시간 콘솔 명령어를 지원하실 계획이 있으신가요?

즐거운 뱁새05. 05. PM 09:52
// 파일 상단
import readline from 'readline';

 function startConsoleInterface() {
    const rl = readline.createInterface({ 
        input: process.stdin, 
        output: process.stdout, 
        prompt: '관리자> ' 
    });

    rl.prompt();
    rl.on('line', (line) => {
        const args = line.trim().split(' ').filter(s => s !== '');
        const cmd = args.shift();

        switch (cmd) {
            case '재시작': {
                console.log("봇을 재시작합니다.");

                process.exit(1);
                break;
            }
            
            case 'exit':
                console.log(" 종료합니다.");
                rl.close();
                process.exit(0);
                break;
                
            default:
                if (cmd) console.log("알 수 없는 명령어");
                break;
        }
        rl.prompt();
    });
}

// 코드 끝
startConsoleInterface();
빛나는 알파카05. 06. AM 12:49
    @commands.command(name="restart")
    @commands.is_owner()
    async def restart(self, ctx: commands.Context):
        await ctx.send("Restarting the bot...")
        await self.bot.close()
        os.execv(sys.executable, ["python"] + sys.argv)

    @commands.command(name="stop")
    @commands.is_owner()
    async def stop(self, ctx: commands.Context):
        await ctx.send("Closing the bot...")
        await self.bot.close()
  • @commands.command(name="exec") @commands.is_owner() async def _exec(self, ctx, *, command: str):
즐거운 뱁새05. 06. AM 01:15

js

즐거운 뱁새05. 06. AM 01:15

python

질문자05. 06. PM 11:00

감사합니다! :)