我目前正在编写一个机器人,我的第一个目标是让机器人欢迎,并向加入或离开的成员说再见,但机器人什么也不发送,甚至不显示任何错误。 @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()
让我们假设on_member_join事件 @commands.Cog.listener()
async def on_member_join(self, member):
# On member joins we find a channel called general and if it exists,
# send an embed welcoming them to our guild
channel = discord.utils.get(member.guild.text_channels, name="welcome")
if
我需要帮助我的代码,我想让我的机器人发送一个消息从顶部的第一个渠道时,一个特定的成员加入,但我得到了错误与if member.id == *id*
@bot.event
async def on_member_join(member):
if member.id == *my id here, i just dont want to show it*
await message.channel.send('Nice guy joined the server!')
@bot.event
async def on_member_join(member):
我使用事件on_member_join尝试创建新成员,但是当我用alt进行测试时,它没有发送消息。
@bot.event
async def on_member_join(member):
embed = discord.Embed(title="Welcome to my server!", description=None, color = discord.Color.magenta())
embed.add_field(name="To get started:", value="•Invite some friends!\n•Check
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 =
我正在修复一个旧的机器人,在意图更改之前,我试图只做一个简单的on_server_join事件,但它不工作,我没有得到任何错误,并假设这是由意图问题引起的。我已经在开发人员门户中启用了这两个特权意图,并尝试将其实现到我的代码中,但它仍然不能正常工作。 import discord
from discord.ext import commands
from discord.utils import get
intents = discord.Intents(messages=True)
client = commands.Bot(command_prefix ='-', in
我想让我的机器人发送一个直接的信息给加入我的服务器的人,并在30秒后给他们角色。我没有任何错误,我的机器人不会崩溃,但它什么也做不了。
我的代码:
@bot.event
async def on_member_join(member):
await member.send('Hi! Welcome to our server, in 30 seconds you will get "Verified" role, please read rules in that time.')
time.sleep(30)
await member.a
我的代码是:
import discord
class MyClient(discord.Client):
async def on_ready(self):
print("Bot ready")
async def on_member_join(member):
await member.send("nice to see u on the server")
client = MyClient()
client.run(My token)
但是消息不会被发送。也许有人可以给我一个正确的和工作的代码。耽误您
我正在尝试让我的机器人响应接受规则的DM消息。
这是我到目前为止所知道的:
@bot.event
async def on_member_join(member):
role = discord.utils.get(member.servers.roles, name='Newcomers') #get role
await bot.add_roles(member, role) #give the role to the user
await bot.member.send("Welcome to the Moderator Bot Server! I w
我需要人帮我处理机器人事件。每当我添加代码时,它都会给出以下错误:
Ignoring exception in on_member_join
Traceback (most recent call last):
File "/home/runner/Tragic-Bot/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 20, in on_memb