만약 !닉네임을 쳤을시 이름을 챗봇이 그대로 읽어주는 코드입니다

def는 정의하다고, 앞에 prefix를 바꿔도 됩니다.

참고로 토큰파일을 만들어야합니다. 토큰은 디스코드에 있습니다.

(참고로 토큰 공개하면 안됩니다. 가끔 토큰 공개해서 디스코드 해킹당하는 경우가 종종 있습니다.)

import discord
from discord.ext import commands
import os

def main():
prefix="!"
intents=discord.Intents.all()

client=commands.Bot(command_prefix=prefix, intents = intents)

@client.command(name="ping")
async def _ping(ctx):
await ctx.send("pong!")

@client.command(name="나이트")
async def hi(ctx):
await ctx.send("hi 나이트")

with open("token.txt", "r") as f:
token = f.read()

client.run(token)

if __name__ == "__main__":
main()

쓸모없어 보여도 디스코드 봇 만들려면 꼭 들어가야 하는 코드입니다