diff --git a/trickortreat/trickortreat.py b/trickortreat/trickortreat.py index 73bbe59..9c3b6cd 100644 --- a/trickortreat/trickortreat.py +++ b/trickortreat/trickortreat.py @@ -9,7 +9,7 @@ from redbot.core import commands, checks, Config, bank from redbot.core.utils.chat_formatting import box, pagify, humanize_number from redbot.core.utils.menus import menu, DEFAULT_CONTROLS -__version__ = "0.1.5" +__version__ = "0.1.6" class TrickOrTreat(commands.Cog): @@ -70,9 +70,9 @@ class TrickOrTreat(commands.Cog): if not candy_type: candy_type = "candies" if number < 0: - return await ctx.send("That doesn't sound fun.") + return await ctx.reply("That doesn't sound fun.") if number == 0: - return await ctx.send("You pretend to eat a candy.") + return await ctx.reply("You pretend to eat a candy.") if candy_type in ["candies", "candy"]: candy_type = "candies" if candy_type in ["lollipops", "lollipop"]: @@ -83,11 +83,11 @@ class TrickOrTreat(commands.Cog): candy_type = "chocolate" candy_list = ["candies", "chocolate", "lollipops", "stars"] if candy_type not in candy_list: - return await ctx.send("That's not a candy type! Use the inventory command to see what you have.") + return await ctx.reply("That's not a candy type! Use the inventory command to see what you have.") if userdata[candy_type] < number: - return await ctx.send(f"You don't have that many {candy_type}.") + return await ctx.reply(f"You don't have that many {candy_type}.") if userdata[candy_type] == 0: - return await ctx.send(f"You contemplate the idea of eating {candy_type}.") + return await ctx.reply(f"You contemplate the idea of eating {candy_type}.") eat_phrase = [ "You leisurely enjoy", @@ -105,7 +105,7 @@ class TrickOrTreat(commands.Cog): ] if candy_type in ["candies", "candy"]: if (userdata["sickness"] + number * 2) in range(70, 95): - await ctx.send("After all that candy, sugar doesn't sound so good.") + await ctx.reply("After all that candy, sugar doesn't sound so good.") yuck = random.randint(1, 10) if yuck == 10: await self.config.user(ctx.author).sickness.set(userdata["sickness"] + 25) @@ -127,7 +127,7 @@ class TrickOrTreat(commands.Cog): await self.config.user(ctx.author).eaten.set(userdata["eaten"] + (userdata["candies"] - lost_candy)) - return await ctx.send( + return await ctx.reply( f"You begin to think you don't need all this candy, maybe...\n*{lost_candy} candies are left behind*" ) @@ -136,7 +136,7 @@ class TrickOrTreat(commands.Cog): lost_candy = userdata["candies"] - random.randint(1, 5) if lost_candy <= 0: await self.config.user(ctx.author).candies.set(0) - message = await ctx.send("...") + message = await ctx.reply("...") await asyncio.sleep(2) await message.edit(content="..........") await asyncio.sleep(2) @@ -146,7 +146,7 @@ class TrickOrTreat(commands.Cog): await self.config.guild(ctx.guild).pick.set(pick + lost_candy) await self.config.user(ctx.author).candies.set(0) await self.config.user(ctx.author).eaten.set(userdata["eaten"] + (userdata["candies"] - lost_candy)) - message = await ctx.send("...") + message = await ctx.reply("...") await asyncio.sleep(2) await message.edit(content="..........") await asyncio.sleep(2) @@ -155,7 +155,7 @@ class TrickOrTreat(commands.Cog): ) pluralcandy = "candy" if number == 1 else "candies" - await ctx.send( + await ctx.reply( f"{random.choice(eat_phrase)} {number} {pluralcandy}. (Total eaten: `{humanize_number(await self.config.user(ctx.author).eaten() + number)}` \N{CANDY})" ) await self.config.user(ctx.author).sickness.set(userdata["sickness"] + (number * 2)) @@ -164,7 +164,7 @@ class TrickOrTreat(commands.Cog): if candy_type in ["chocolates", "chocolate"]: pluralchoc = "chocolate" if number == 1 else "chocolates" - await ctx.send( + await ctx.reply( f"{random.choice(eat_phrase)} {number} {pluralchoc}. You feel slightly better!\n*Sickness has gone down by {number * 10}*" ) new_sickness = userdata["sickness"] - (number * 10) @@ -176,7 +176,7 @@ class TrickOrTreat(commands.Cog): if candy_type in ["lollipops", "lollipop"]: pluralpop = "lollipop" if number == 1 else "lollipops" - await ctx.send( + await ctx.reply( f"{random.choice(eat_phrase)} {number} {pluralpop}. You feel slightly better!\n*Sickness has gone down by {number * 20}*" ) new_sickness = userdata["sickness"] - (number * 20) @@ -188,7 +188,7 @@ class TrickOrTreat(commands.Cog): if candy_type in ["stars", "star"]: pluralstar = "star" if number == 1 else "stars" - await ctx.send( + await ctx.reply( f"{random.choice(eat_phrase)} {number} {pluralstar}. You feel great!\n*Sickness has been reset*" ) await self.config.user(ctx.author).sickness.set(0) @@ -210,16 +210,16 @@ class TrickOrTreat(commands.Cog): candy_now = await self.config.user(ctx.author).candies() credits_name = await bank.get_currency_name(ctx.guild) if pieces <= 0: - return await ctx.send("Not in this reality.") + return await ctx.reply("Not in this reality.") candy_price = int(round(await bank.get_balance(ctx.author)) * 0.04) * pieces if candy_price in range(0, 10): candy_price = pieces * 10 try: await bank.withdraw_credits(ctx.author, candy_price) except ValueError: - return await ctx.send(f"Not enough {credits_name} ({candy_price} required).") + return await ctx.reply(f"Not enough {credits_name} ({candy_price} required).") await self.config.user(ctx.author).candies.set(candy_now + pieces) - await ctx.send(f"Bought {pieces} candies with {candy_price} {credits_name}.") + await ctx.reply(f"Bought {pieces} candies with {candy_price} {credits_name}.") @commands.guild_only() @commands.command() @@ -228,7 +228,7 @@ class TrickOrTreat(commands.Cog): """Show the candy eating leaderboard.""" userinfo = await self.config._all_from_scope(scope="USER") if not userinfo: - return await ctx.send("No one has any candy.") + return await ctx.reply("No one has any candy.") async with ctx.typing(): sorted_acc = sorted(userinfo.items(), key=lambda x: x[1]["eaten"], reverse=True) # Leaderboard logic from https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/cogs/economy/economy.py#L445 @@ -275,7 +275,7 @@ class TrickOrTreat(commands.Cog): for page in pagify(temp_msg, delims=["\n"], page_length=1000): embed = discord.Embed( colour=0xF4731C, - description=box(f"\N{CANDY} Global leaderboard \N{CANDY}", lang="prolog") + (box(page, lang="md")), + description=box(f"\N{CANDY} Global Leaderboard \N{CANDY}", lang="prolog") + (box(page, lang="md")), ) embed.set_footer(text=f"Page {humanize_number(pages)}/{humanize_number(math.ceil(len(temp_msg) / 1500))}") pages += 1 @@ -350,7 +350,7 @@ class TrickOrTreat(commands.Cog): found = round((chance / 100) * to_pick) await self.config.user(ctx.author).candies.set(candies + found) await self.config.guild(ctx.guild).pick.set(to_pick - found) - message = await ctx.send("You start searching the area for candy...") + message = await ctx.reply("You start searching the area for candy...") await asyncio.sleep(3) await message.edit(content=f"You found {found} \N{CANDY}!") @@ -363,7 +363,7 @@ class TrickOrTreat(commands.Cog): candy_users = await self.config._all_from_scope(scope="USER") valid_user = list(set(guild_users) & set(candy_users)) if not valid_user: - return await ctx.send("No one has any candy yet!") + return await ctx.reply("No one has any candy yet!") if not user: picked_user = self.bot.get_user(random.choice(valid_user)) elif user == ctx.author or user == user.bot: @@ -380,25 +380,25 @@ class TrickOrTreat(commands.Cog): new_picked_candy_now = await self.config.user(new_picked_user).candies() if chance in range(24, 25): if new_picked_candy_now == 0: - message = await ctx.send("You see an unsuspecting guildmate...") + message = await ctx.reply("You see an unsuspecting guildmate...") await asyncio.sleep(random.randint(3, 6)) return await message.edit( content=f"There was nothing in {picked_user.name}#{picked_user.discriminator}'s pockets, so you picked {new_picked_user.name}#{new_picked_user.discriminator}'s pockets but they had no candy either!" ) else: - message = await ctx.send("You see an unsuspecting guildmate...") + message = await ctx.reply("You see an unsuspecting guildmate...") await asyncio.sleep(random.randint(3, 6)) return await message.edit( content=f"There was nothing in {picked_user.name}#{picked_user.discriminator}'s pockets, so you looked around again... you saw {new_picked_user.name}#{new_picked_user.discriminator} in the distance, but you didn't think you could catch up..." ) if chance in range(10, 20): - message = await ctx.send("You start sneaking around in the shadows...") + message = await ctx.reply("You start sneaking around in the shadows...") await asyncio.sleep(random.randint(3, 6)) return await message.edit( content=f"You snuck up on {picked_user.name}#{picked_user.discriminator} and tried picking their pockets but there was nothing there!" ) else: - message = await ctx.send("You start looking around for a target...") + message = await ctx.reply("You start looking around for a target...") await asyncio.sleep(random.randint(3, 6)) return await message.edit(content="You snuck around for a while but didn't find anything.") user_candy_now = await self.config.user(ctx.author).candies() @@ -407,7 +407,7 @@ class TrickOrTreat(commands.Cog): multip = 0.7 pieces = round(picked_candy_now * multip) if pieces <= 0: - message = await ctx.send("You stealthily move over to an unsuspecting person...") + message = await ctx.reply("You stealthily move over to an unsuspecting person...") await asyncio.sleep(4) return await message.edit(content="You found someone to pickpocket, but they had nothing but pocket lint.") chance = random.randint(1, 25) @@ -417,13 +417,13 @@ class TrickOrTreat(commands.Cog): "You see someone with a full candy bag...", ] if chance <= 10: - message = await ctx.send("You creep closer to the target...") + message = await ctx.reply("You creep closer to the target...") await asyncio.sleep(random.randint(3, 5)) return await message.edit(content="You snuck around for a while but didn't find anything.") if chance > 18: await self.config.user(picked_user).candies.set(picked_candy_now - pieces) await self.config.user(ctx.author).candies.set(user_candy_now + pieces) - message = await ctx.send(random.choice(sneak_phrases)) + message = await ctx.reply(random.choice(sneak_phrases)) await asyncio.sleep(4) await message.edit(content="There seems to be an unsuspecting victim in the corner...") await asyncio.sleep(4) @@ -433,7 +433,7 @@ class TrickOrTreat(commands.Cog): if chance in range(11, 17): await self.config.user(picked_user).candies.set(picked_candy_now - round(pieces / 2)) await self.config.user(ctx.author).candies.set(user_candy_now + round(pieces / 2)) - message = await ctx.send(random.choice(sneak_phrases)) + message = await ctx.reply(random.choice(sneak_phrases)) await asyncio.sleep(4) await message.edit(content="There seems to be an unsuspecting victim in the corner...") await asyncio.sleep(4) @@ -441,7 +441,7 @@ class TrickOrTreat(commands.Cog): content=f"You stole {round(pieces/2)} \N{CANDY} from {picked_user.name}#{picked_user.discriminator}!" ) else: - message = await ctx.send(random.choice(sneak_phrases)) + message = await ctx.reply(random.choice(sneak_phrases)) await asyncio.sleep(4) noise_msg = [ "You hear a sound behind you! When you turn back, your target is gone.", @@ -563,7 +563,7 @@ class TrickOrTreat(commands.Cog): "The house you were approaching just turned the light off.", "The wind starts to pick up as you look for the next house...", ] - return await message.channel.send(random.choice(messages)) + return await message.reply(random.choice(messages)) await self.config.user(message.author).last_tot.set(str(now)) candy = random.randint(1, 25) lollipop = random.randint(0, 100) @@ -627,7 +627,7 @@ class TrickOrTreat(commands.Cog): "*You knock on the door...*", "*There's a movement in the shadows by the side of the house...*", ] - bot_talking = await message.channel.send(random.choice(walking_messages)) + bot_talking = await message.reply(random.choice(walking_messages)) await asyncio.sleep(random.randint(5, 8)) door_messages = [ "*The door slowly opens...*",