前提・実現したいこと
Discord.pyの機能をDiscord.jsでやりたいんですけど、どうすればいいんでしょうか。コードを教えてもらえるとありがたいです。
発生している問題・エラーメッセージ
エラーメッセージ
なし
コードの挿入
Discord BOT
import discord
from discord.ext import commands
import asyncio
import datetime
import os
web-server
from sanic import Sanic, Request, response
app = Sanic(name)
@app.route('/')
async def index(request: Request):
return response.text('running')
from discord import Intents
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="we.", intents = intents)
@bot.event
async def on_ready():
print(discord.version)
print('Server is ready')
await app.create_server('0.0.0.0', 8080, access_log=False, return_asyncio_server=True)
print('bot is ready')
@bot.event
async def on_member_join(member):
embed = discord.Embed(
color = 0x00f2ff,
title = f"",
description = f"{member.name}がサーバーに参加しました",
timestamp = datetime.datetime.utcnow()
)
channel = bot.get_channel(チャンネルID)
await channel.send(embed = embed)
@bot.event
async def on_member_remove(member):
embed = discord.Embed(
color = 0x00f2ff,
title = f"",
description = f"{member.name}がサーバーから退出しました",
timestamp = datetime.datetime.utcnow()
)
channel = bot.get_channel(チャンネルID)
await channel.send(embed = embed)
bot.run (os.getenv("token"))
試したこと
Discord.jsについて色々と調べた
ここに問題に対して試したことを記載してください。
回答1件
あなたの回答
tips
プレビュー