mass send added

This commit is contained in:
ggodot 2025-03-10 00:09:35 +01:00
parent 49f4039844
commit d953280373

View File

@ -17,7 +17,7 @@ async def on_ready():
@bot.slash_command(guild_ids=g_ids, name = "ahoj", description="Je slušností pozdravit") @bot.slash_command(guild_ids=g_ids, name = "ahoj", description="Je slušností pozdravit")
async def summary(ctx): async def ahoj(ctx):
await ctx.channel.trigger_typing() # that bot is typing await ctx.channel.trigger_typing() # that bot is typing
try: try:
@ -84,48 +84,58 @@ async def shame(ctx, hranice: Option(int, description = "Where is the line", req
await ctx.channel.trigger_typing() # that bot is typing await ctx.channel.trigger_typing() # that bot is typing
role = await check_role(ctx, ctx.author) try:
await ctx.respond("Rado se, pracuju na tom.")
except:
await ctx.send("Rado se, pracuju na tom.")
if role == False: users = await get_bank_data()
try:
await ctx.respond("Já nevěřit tvým šprímům, ty více ukázati musíš.")
except:
await ctx.send("Já nevěřit tvým šprímům, ty více ukázati musíš.")
elif role == True: loser_dict = {}
try: em = discord.Embed(title = "List of shame", color = discord.Color.red())
await ctx.respond("Rado se, pracuju na tom.")
except:
await ctx.send("Rado se, pracuju na tom.")
users = await get_bank_data() for user in users:
if users[user]["wallet"] <= hranice:
loser_dict = {} #creates dictionary of needed info
em = discord.Embed(title = "List of shame", color = discord.Color.red()) debt = users[user]["wallet"]
if int(users[user]["wallet"]) in loser_dict:
loser_dict[debt].append(user)
else:
loser_dict[debt] = []
loser_dict[debt].append(user)
#sortes
loser_dict = dict(sorted(loser_dict.items()))
for user in users: # formats string to desired format
if users[user]["wallet"] <= hranice: for loser in loser_dict:
i = 0
while i < len(loser_dict[loser]):
loser_dict[loser][i] = f'<@{loser_dict[loser][i]}>'
i += 1
#creates dictionary of needed info em.add_field(name = loser, value = ", ".join(loser_dict[loser]), inline = False)
debt = users[user]["wallet"]
if int(users[user]["wallet"]) in loser_dict:
loser_dict[debt].append(user)
else:
loser_dict[debt] = []
loser_dict[debt].append(user)
#sortes
loser_dict = dict(sorted(loser_dict.items()))
# formats string to desired format await ctx.author.send(embed = em)
for loser in loser_dict:
i = 0
while i < len(loser_dict[loser]):
loser_dict[loser][i] = f'<@{loser_dict[loser][i]}>'
i += 1
em.add_field(name = loser, value = ", ".join(loser_dict[loser]), inline = False)
await ctx.author.send(embed = em) @bot.slash_command(guild_ids=g_ids, name="laska_k_svetu", descritpion="Auto send message to users in shame")
async def laska_k_svetu(ctx, message: Option(str, descritpion = "What to send", required = True), hranice: Option(int, description = "Where is the line", required = False) = -1):
await ctx.channel.trigger_typing() # that bot is typing
try:
await ctx.respond("Rado se, pracuju na tom.")
except:
await ctx.send("Rado se, pracuju na tom.")
users = await get_bank_data()
for user in users:
if users[user]["wallet"] <= hranice:
user_obj = await bot.fetch_user(int(user))
await user_obj.send(f"{message}. Protože máš {users[user]["wallet"]} bodiku.")
@bot.slash_command(guild_ids=g_ids, name="payout", descritpion="Pays user given amount") @bot.slash_command(guild_ids=g_ids, name="payout", descritpion="Pays user given amount")
@ -140,14 +150,6 @@ async def payout(ctx, komu: Option(str, description = "Komu to sebrat?", require
for mem in komu.split(): for mem in komu.split():
mem = mem.strip("<>@") mem = mem.strip("<>@")
role = await check_role(ctx, ctx.author)
if role == False:
try:
await ctx.respond("Větší snahy ze strany tvé nastati budou než já podlehnu.")
except:
await ctx.send("Větší snahy ze strany tvé nastati budou než já podlehnu.")
break
member = await bot.fetch_user(int(mem)) member = await bot.fetch_user(int(mem))
await open_account(mem) await open_account(mem)
@ -155,7 +157,7 @@ async def payout(ctx, komu: Option(str, description = "Komu to sebrat?", require
await update_bank(member,kolik) await update_bank(member,kolik)
await ctx.send(f"{member.name} dostal vyplaceno {kolik} bodíčků!") await ctx.send(f"<@{mem}> dostal vyplaceno {kolik} bodíčků!")
@bot.slash_command(guild_ids=g_ids, name = "cut", description = "Takes bodičky from users") @bot.slash_command(guild_ids=g_ids, name = "cut", description = "Takes bodičky from users")
async def cut(ctx, komu: Option(str, description = "Komu mam sebrat bodiky?", required = True),kolik: Option(int, descritpion = "Kolik mam sebrat bodičku?", required = True)): async def cut(ctx, komu: Option(str, description = "Komu mam sebrat bodiky?", required = True),kolik: Option(int, descritpion = "Kolik mam sebrat bodičku?", required = True)):
@ -169,14 +171,6 @@ async def cut(ctx, komu: Option(str, description = "Komu mam sebrat bodiky?", re
for mem in komu.split(): for mem in komu.split():
mem = mem.strip("<>@") mem = mem.strip("<>@")
role = await check_role(ctx, ctx.author)
if role == False:
try:
await ctx.respond("Větší snahy ze strany tvé nastati budou než já podlehnu.")
except:
await ctx.send("Větší snahy ze strany tvé nastati budou než já podlehnu.")
break
member = await bot.fetch_user(int(mem)) member = await bot.fetch_user(int(mem))
@ -184,7 +178,7 @@ async def cut(ctx, komu: Option(str, description = "Komu mam sebrat bodiky?", re
await update_bank(member,int(kolik)*-1) await update_bank(member,int(kolik)*-1)
await ctx.send(f"{member.name} dostal zabaveno {kolik} bodíčků!") await ctx.send(f"<@{mem}> dostal zabaveno {kolik} bodíčků!")
async def open_account(id): async def open_account(id):