@bot.event
async def on_ready():
for guild in bot.guilds:
for member in guild.members:
values = {
"_id": member.id,
"guild_id": guild.id,
"warns": 0,
"reasons": []
}
server_values = {
"_id": guild.id,
"case": 0
}
if collusers.count_documents({"_id": member.id, "guild_id": guild.id}) == 0:
collusers.insert_one(values)
if collusers.count_documents({"_id": guild_id}) == 0:
collservers.insert_one(server_values)
@bot.event
async def on_member_join(member):
values = {
"_id": member.id,
"guild_id": guild.id,
"warns": 0,
"reasons": []
}
if collusers.count_documents({"_id": member.id, "guild_id": guild.id}) == 0:
collusers.insert_one(values)
@bot.event
async def on_guild_join(guild):
server_values = {
"_id": guild.id,
"case": 0
}
if collusers.count_documents({"_id": guild_id}) == 0:
collservers.insert_one(server_values)
@commands.command(name="warn")
async def give_warn(self, ctx, member: discord.Member, *, reason="Причина"):
if self.collusers.find_one({"_id": member.id, "guild_id": ctx.guild.id})["warns"] >= 3:
self.collusers.update_one(
{
"_id": member.id,
"guild_id": ctx.guild.id
},
{
"$set": {
"warns": 0,
"reasons": []
}
}
)
role = discord.utils.get(ctx.guild.roles, id=963459304617312296)
await member.add_roles(role)
else:
self.collservers.update_one(
{
"_id": ctx.guild.id
},
{
"$inc": {
"case": 1
}
}
)
self.collusers.update_one(
{
"_id": member.id,
"guild_id": ctx.guild.id
},
{
"$inc": {
"warns": 1
},
"$push": {
"reasons": {
"author_id": ctx.author.id,
"case": self.collservers.find_one({"_id": ctx.guild.id})["case"],
"reason": reason
}
}
}
)
await ctx.send(f"{ctx.author} выдал предупреждение {member} | case: {self.collservers.find_one({"_id": ctx.guild.id})["case"]}")
Ошибка: C:\Users\pasha\Desktop\bot>py bot.py
File "C:\Users\pasha\Desktop\bot\bot.py", line 573
await ctx.send(f"{ctx.author} выдал предупреждение {member} | case: {self.collservers.find_one({"_id": ctx.guild.id})["case"]}")
^
SyntaxError: f-string: unmatched '{'