from discord.ext import commands
from discord.ext import tasks
import random
import typing
from discord import Status
from discord import Activity, ActivityType
from discord import Member
from discord.ext.commands import Bot
from asyncio import sleep
intents = discord.Intents()
intents.members =
@client.event
async def on_member_join(ctx, member : discord.member):
print(f'{time} {member} has joined {ctx.guild.name}, Server ID: {ctx.guild.id}')
with open('join-log.txt', 'a') as joinlog:
joinlog.writelines(f'{time} {member} has joined {ctx.guild.nam
我正在尝试制作一个与Discord.py库不协调的机器人。带有@client.command()装饰器的命令对我来说工作得很好,但我尝试过的事件命令都不工作。 @client.event
async def on_member_join(member):
channel = client.get_channel(ChannelId) #I did define channel Id in my code
await channel.send("someone has joined")
@client.event
async def on_member_rem
我正在设置一个不和谐的机器人,我想让机器人在"ban“和"kick”命令后发送确认或错误消息,有人能帮助我吗? 我尝试使用相同的参数创建另一个单独的命令,只是让它发送预期的消息。 @client.event
async def on_ready():
print('Bot is ready!')
@client.event
async def on_member_join(ctx, member):
print(f'{member} has joined {ctx.guild.name}.')
@client.event
a
我有一个翻转命令,可以返回正面或反面,在我添加on_message函数之前,它一直工作得很好。我对SO做了一些研究,并阅读了文档和,它说要在on_message函数中包含await bot.process_commands(message),但这并没有解决问题,翻转命令仍然不起作用。如果我删除了on_message函数,一切都会正常工作。
bot.py
import discord
from discord.ext import commands
import random
# from app bot user
# click to reveal
TOKEN = 'toke
我有一个不和谐的机器人驻留在多个服务器上,但是我希望每个服务器都有加入消息,或者确保我的机器人只向加入其中一个服务器的人发送欢迎消息。 @client.event #Send new members of the server a message
async def on_member_join(member): #Run when a member joins
await member.create_dm() #Create a DM chat with the new user
await member.dm_channel.send(f"Heya, {membe
我目前正在编写一个机器人,我的第一个目标是让机器人欢迎,并向加入或离开的成员说再见,但机器人什么也不发送,甚至不显示任何错误。 @client.event
async def on_member_join(member):
print(" System: A member has joined the server!")
def sprint(str):
for c in str + '\n':
sys.stdout.write(c)
sys.stdout.flush()
你好,我一直在尝试编辑这段代码,让它工作,但我被困在一个点上,我得到了这个错误: File "main.py", line 24, in on_member_join
await client.send_message(member, DMMessage)
AttributeError: 'Client' object has no attribute 'send_message' 我认为这与意图有关,但经过大量研究和时间,我无法修复它,谁能解释一下我如何修复这个问题? 我的代码供参考: import discord
import o
创建一个join和leave消息函数,用于当人们加入和离开我的服务器时,但是它似乎不起作用,代码看起来完全没有问题。没有错误。我遗漏了什么吗?
# are any of these causing the issues?
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
client = commands.Bot(command_prefix='-')
client.remove_command('help'