当用户连接到一个专用的语音通道(ID为1191737629281107978)时,该功能必须创建一个克隆的语音通道,当没有人时,该功能将删除该通道。
@client.event
async def on_voice_state_update(member, before, after):
possible_channel_name = f'new {member}`s channel'
if after.channel.id == 1191737629281107978:
temp_channel = await after.channel.clone(name=possible_channel_name)
await member.move_to(temp_channel)
if before.channel.name == possible_channel_name and len(before.channel.members) == 0:
await before.channel.delete()
字符串
它特别的作品,它使一个新的渠道,但不删除它在年底,并与2错误:
line 58, in on_voice_state_update
if after.channel.id == 1191737629281107978:
^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'
型
和
line 61, in on_voice_state_update
if before.channel.name == possible_channel_name and len(before.channel.members) == 0:
^^^^^^^^^^^^^^^^^^^
型
我查了查,意图可能有问题,但它有
intents = discord.Intents.all()
intents.members = True
client = commands.Bot(intents=intents, command_prefix="/")
型
和一切可以打开不和谐的发展网站(已注册的网关意图太).此外,在此之后,我recconnected机器人到服务器几次.我使用discord.py和这些bibliotecks:
import discord
from discord.ext import commands
from datetime import datetime
from PIL import Image, ImageDraw
import asyncio
import configure
import sqlite3
import requests
import io
型
1条答案
按热度按时间bnl4lu3b1#
您可以添加检查以确保
before.channel
和after.channel
不是None
:字符串