问题描述
我与许多合作伙伴的服务器一起工作,共享禁止突袭的禁令。通常,我会得到一个user_id列表和一个禁令原因。然后使用dyno bot禁止他们,因为dyno bot可以禁止不在您服务器中的成员。但是,现在我将禁止日志数据库添加到我的机器人中,我希望能够禁止不在服务器中的成员。
@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx,member : discord.Member,*,reason=None):
new_color = stuff
hex_color = stuff
if reason == None:
embed = discord.Embed(title=f"Woah {ctx.author.name},Make sure you provide a reason!",color=int(hex_color,16))
await ctx.send(embed=embed)
else:
dmban=(f"You have been banned from {ctx.guild.name} for '{reason}'.")
embed=discord.Embed(title=f"{member.name} has been banned from {ctx.guild.name} for {reason}",16))
embed.add_field(name=f":newspaper: {reason}",value=f"User id: {member.id}",inline=True)
embed.add_field(name="User joined:",value=member.joined_at,inline=True)
inlul = client.get_channel(channel_id)
now = datetime.now()
formatted_date = now.strftime('%Y-%m-%d %H:%M:%S')
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
sql = ("INSERT INTO banlog(mod_name,mod_id,reason,datetime,ban_name,ban_id) VALUES(?,?,?)")
val = (ctx.author.name,ctx.author.id,formatted_date,member.name,member.id)
cursor.execute(sql,val)
db.commit()
cursor.close()
db.close()
await member.send(dmban)
await guild.ban(discord.Object(id=member_id),reason=reason)
await inlul.send(embed=embed)
我尝试使用await guild.ban(discord.Object(id=member_id)
,我在github页面上找到了有关使用它通过user_id禁止的信息。但是对我来说,它不会禁止用户,但是会将禁止添加到数据库中。我不确定是否要为member_id创建一个变量。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)