문제 이해: 명령이 작동하지 않음
Discord.py 라이브러리를 사용할 때 일부 사용자는 명령이 실행되지 않는 예기치 않은 동작을 경험합니다. 봇이 활성화된 것 같지만요. 이 문제는 on_message 이벤트 핸들러로 인해 발생할 수 있습니다.
문제 해결: bot.process_commands(message) 추가
Discord.py 문서에 따르면 기본 on_message 이벤트 핸들러는 추가 명령이 실행되는 것을 방지합니다. 이 문제를 해결하려면 사용자 정의 on_message 함수 끝에 bot.process_commands(message) 줄을 포함해야 합니다.
안내 문서 참조:
Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message.
구현 예:
import discord import asyncio from discord.ext import commands bot = commands.Bot(command_prefix = '-') @bot.event async def on_ready(): print('Logged in as') print(bot.user.name) print(bot.user.id) print('------') @bot.event async def on_message(message): # do some extra stuff here await bot.process_commands(message)
다음을 따르세요. 지침에 따라 사용자 정의 on_message 이벤트 핸들러의 기능을 유지하면서 명령이 계속해서 원활하게 작동하도록 할 수 있습니다.
위 내용은 on_message를 사용자 정의한 후 Discord.py 봇 명령이 작동하지 않는 이유는 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Python은 해석 된 언어이지만 편집 프로세스도 포함됩니다. 1) 파이썬 코드는 먼저 바이트 코드로 컴파일됩니다. 2) 바이트 코드는 Python Virtual Machine에 의해 해석되고 실행됩니다. 3)이 하이브리드 메커니즘은 파이썬이 유연하고 효율적이지만 완전히 편집 된 언어만큼 빠르지는 않습니다.

USEAFORLOOPHENTERATINGOVERASERASERASPECIFICNUMBEROFTIMES; USEAWHILLOOPWHENTINUTIMONDITINISMET.FORLOOPSAREIDEALFORKNOWNSEDINGENCENCENS, WHILEWHILELOOPSSUITSITUATIONS WITHERMINGEDERITERATIONS.

Pythonloopscanleadtoerrors likeinfiniteloops, modifyinglistsdizeration, off-by-by-byerrors, zero-indexingissues, andnestedloopineficiencies.toavoidthese : 1) aing'i

ForloopSareadvantageForkNowniTerations 및 Sequence, OffingSimplicityAndInamicConditionSandunkNowniTitionS 및 ControlOver Terminations를 제공합니다

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

WebStorm Mac 버전
유용한 JavaScript 개발 도구

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.