簡體   English   中英

請幫助我使用我的 python discord 機器人

[英]Please help me with my python discord bot

我想在 python 中制作一個 discord 機器人,用於搜索成員的姓名中是否包含某些特定的單詞/字符(例如“hello”或“ЯΛY”),如果有,他們會被踢。 我已經嘗試首先完全打印出服務器中的所有用戶名,但從那時起我無法進一步前進,因為我不知道如何將這些名稱添加到變量/列表中,從那時起我可以掃描它。 如果有人對我已經制作的代碼感興趣:

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True
client = commands.Bot(intents=intents, command_prefix='?')

@client.command()
async def members(ctx):
    for guild in client.guilds:
        for member in guild.members:
            print(member)


client.run("funny token")

你會想要他們的用戶名,所以從member.name中獲取然后檢查他們的名字中是否有 substring,如果它包含你列入黑名單的文本,然后調用 member 的 kick 方法。 查看API 參考。 所以:

if "someText" in member.name:
    member.kick(reason)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM