diff --git a/__pycache__/awards.cpython-313.pyc b/__pycache__/awards.cpython-313.pyc new file mode 100644 index 0000000..da9b77a Binary files /dev/null and b/__pycache__/awards.cpython-313.pyc differ diff --git a/__pycache__/extra.cpython-313.pyc b/__pycache__/extra.cpython-313.pyc new file mode 100644 index 0000000..068f6bf Binary files /dev/null and b/__pycache__/extra.cpython-313.pyc differ diff --git a/__pycache__/food.cpython-313.pyc b/__pycache__/food.cpython-313.pyc new file mode 100644 index 0000000..252b1c4 Binary files /dev/null and b/__pycache__/food.cpython-313.pyc differ diff --git a/__pycache__/items.cpython-313.pyc b/__pycache__/items.cpython-313.pyc new file mode 100644 index 0000000..d76c9f8 Binary files /dev/null and b/__pycache__/items.cpython-313.pyc differ diff --git a/__pycache__/quests.cpython-313.pyc b/__pycache__/quests.cpython-313.pyc new file mode 100644 index 0000000..e03c8ab Binary files /dev/null and b/__pycache__/quests.cpython-313.pyc differ diff --git a/__pycache__/responses.cpython-313.pyc b/__pycache__/responses.cpython-313.pyc new file mode 100644 index 0000000..bada79c Binary files /dev/null and b/__pycache__/responses.cpython-313.pyc differ diff --git a/__pycache__/songs.cpython-313.pyc b/__pycache__/songs.cpython-313.pyc new file mode 100644 index 0000000..add661c Binary files /dev/null and b/__pycache__/songs.cpython-313.pyc differ diff --git a/__pycache__/trivia.cpython-313.pyc b/__pycache__/trivia.cpython-313.pyc new file mode 100644 index 0000000..ec229f7 Binary files /dev/null and b/__pycache__/trivia.cpython-313.pyc differ diff --git a/__pycache__/workers.cpython-313.pyc b/__pycache__/workers.cpython-313.pyc new file mode 100644 index 0000000..376d8ab Binary files /dev/null and b/__pycache__/workers.cpython-313.pyc differ diff --git a/awards.py b/awards.py new file mode 100644 index 0000000..4764715 --- /dev/null +++ b/awards.py @@ -0,0 +1,18 @@ +all_awards = ["first_task", "set_banner", "logo_approved", "ten_tasks", "thirty_tasks", "twohundred_customers", "sevenhundred_customers", "fifteenhundred_customers"] + +awards = { +"set_banner": {"name": "Marketing Expert", "emoji": "<:MarketingExpert:1328604611811999764>", "grey_emoji": "<:MarketingExpertA:1328604929442447381>", "description": "Set your banner for the first time"}, +"logo_approved": {"name": "Graphic Designer", "emoji": "<:GraphicDesigner:1328575306809872446>", "grey_emoji": "<:GraphicDesignerA:1328576242856755304>", "description": "Get a logo approved for the first time"}, +"worker": {"name": "Teamwork", "emoji": "<:Teamwork:1328580116682506320>", "grey_emoji": "<:TeamworkA:1328580963390717974>", "description": "Hire your first worker"}, +"broken_pole": {"name": "Sad Fisherman", "emoji": "<:SadFisherman:1328584022258876487>", "grey_emoji": "<:SadFishermanA:1328584079452536832>", "description": "Break your first fishing pole"}, +"first_task": {"name": "Hardworker", "emoji": "<:Hardworker:1328590454362607626>", "grey_emoji": "<:HardworkerA:1328591604675641377>", "description": "Complete your first weekly task"}, +"ten_tasks": {"name": "Busy Entrepreneur", "emoji": "<:BusyEntrepreneur:1328586064729866310>", "grey_emoji": "<:BusyEntrepreneurA:1328586447141343273>", "description": "Complete 10 weekly tasks"}, +"thirty_tasks": {"name": "Boss & CEO", "emoji": "<:BossAndCEO:1328588381755805807>", "grey_emoji": "<:BossAndCEOa:1328588893875863637>", "description": "Complete 30 weekly tasks"}, +"fivehundred_customers": {"name": "Poppin' Business", "emoji": "<:PoppinBusiness:1328605926672039968>", "grey_emoji": "<:PoppinBusinessA:1328606234416250880>", "description": "Reach 500 customers"}, +"fifteenhundred_customers": {"name": "Hotspot", "emoji": "<:Hotspot:1328608005423366146>", "grey_emoji": "<:HotspotA:1328608591783002173>", "description": "Reach 1500 customers"}, +"threethousand_customers": {"name": "The Talk of the Town", "emoji": "<:TalkOfTheTown:1328610599911030836>", "grey_emoji": "<:TalkOfTheTownA:1328610919722385530>", "description": "Reach 3000 customers"}, +"fivethousand_customers": {"name": "Michelin Restaurant", "emoji": "<:MichelinRestaurant:1328612407941136414>", "grey_emoji": "<:MichelinRestaurantA:1328612738490175529>", "description": "Reach 5000 customers"}, +"fivehundred_bbux": {"name": "Pretty Penny", "emoji": "<:PrettyPenny:1328597160203391058>", "grey_emoji": "<:PrettyPennyA:1328597436825997332>", "description": "Have a balance of 500 BB"}, +"thousand_bbux": {"name": "Moneybags", "emoji": "<:Moneybags:1328599838593519677>", "grey_emoji": "<:MoneybagsA:1328600139966971924>", "description": "Have a balance of 1000 BB"}, +"twothousand_bbux": {"name": "Stacks on Stacks", "emoji": "<:StacksOnStacks:1328601339088998401>", "grey_emoji": "<:StacksOnStacksA:1328601896767717457>", "description": "Have a balance of 2000 BB"} +} diff --git a/cogs/__pycache__/bot.cpython-313.pyc b/cogs/__pycache__/bot.cpython-313.pyc new file mode 100644 index 0000000..82319f3 Binary files /dev/null and b/cogs/__pycache__/bot.cpython-313.pyc differ diff --git a/cogs/__pycache__/cookoff.cpython-313.pyc b/cogs/__pycache__/cookoff.cpython-313.pyc new file mode 100644 index 0000000..b71e956 Binary files /dev/null and b/cogs/__pycache__/cookoff.cpython-313.pyc differ diff --git a/cogs/__pycache__/dev.cpython-313.pyc b/cogs/__pycache__/dev.cpython-313.pyc new file mode 100644 index 0000000..220ba3c Binary files /dev/null and b/cogs/__pycache__/dev.cpython-313.pyc differ diff --git a/cogs/__pycache__/help.cpython-313.pyc b/cogs/__pycache__/help.cpython-313.pyc new file mode 100644 index 0000000..c350e06 Binary files /dev/null and b/cogs/__pycache__/help.cpython-313.pyc differ diff --git a/cogs/__pycache__/shop.cpython-313.pyc b/cogs/__pycache__/shop.cpython-313.pyc new file mode 100644 index 0000000..0f72296 Binary files /dev/null and b/cogs/__pycache__/shop.cpython-313.pyc differ diff --git a/cogs/__pycache__/tasks.cpython-313.pyc b/cogs/__pycache__/tasks.cpython-313.pyc new file mode 100644 index 0000000..01320d7 Binary files /dev/null and b/cogs/__pycache__/tasks.cpython-313.pyc differ diff --git a/cogs/__pycache__/tempcook.cpython-313.pyc b/cogs/__pycache__/tempcook.cpython-313.pyc new file mode 100644 index 0000000..8f4f87d Binary files /dev/null and b/cogs/__pycache__/tempcook.cpython-313.pyc differ diff --git a/cogs/__pycache__/user.cpython-313.pyc b/cogs/__pycache__/user.cpython-313.pyc new file mode 100644 index 0000000..30e17f4 Binary files /dev/null and b/cogs/__pycache__/user.cpython-313.pyc differ diff --git a/cogs/bot.py b/cogs/bot.py index 0772fd1..1ed1ce2 100644 --- a/cogs/bot.py +++ b/cogs/bot.py @@ -2,7 +2,7 @@ from discord.ext import commands import datetime - +import string import time import subprocess import traceback @@ -46,7 +46,7 @@ async def run_cmd(self, cmd: str) -> str: @commands.Cog.listener() async def on_guild_remove(self, guild): try: - embed = discord.Embed(colour=0xa82021, description="Please take the time to fill out [this exit form](https://forms.gle/wkMNiSanpnpeLTt88). Thanks for using Restaurant Bot.") + embed = discord.Embed(colour=0x8980d9, description="Please take the time to fill out [this exit form](https://forms.gle/wkMNiSanpnpeLTt88). Thanks for using Bistro Bot.") embed.set_author(name="Goodbye!") await self.bot.get_user(guild.owner.id).send(embed=embed) except: @@ -78,9 +78,9 @@ async def pull(self, ctx): async def ban(self, ctx, id:int, *, reason): if ctx.author.id == 396153668820402197: user = self.bot.get_user(id) - await ctx.send(f"**{user}** was banned from using Restaurant.") + await ctx.send(f"**{user}** was banned from using Bistro.") db.utility.update_one({"utility": "banlist"}, {"$push":{"banned": user.id}}) - embed = discord.Embed(colour=0xa82021, description=f"You were banned from using **Restaurant**. Reason: `{reason}`\n\nIf you would like to appeal, visit http://paixlukee.ml/restaurant/appeal.html.") + embed = discord.Embed(colour=0x8980d9, description=f"You were banned from using **Bistro**. Reason: `{reason}`\n\nIf you would like to appeal, visit http://paixlukee.ml/restaurant/appeal.html.") embed.set_image(url="http://paixlukee.ml/m/6UK4U.jpg") await user.send(embed=embed) else: @@ -90,11 +90,11 @@ async def ban(self, ctx, id:int, *, reason): async def shell(self, ctx, *, code): if ctx.author.id == 396153668820402197: embed = discord.Embed(description=f"```css\nConnecting to shell..```") - embed.set_author(name="Please Wait.", icon_url=self.bot.user.avatar_url) + embed.set_author(name="Please Wait.", icon_url=ctx.me.avatar.with_format('png')) msg = await ctx.send(embed=embed) shell = await self.run_cmd(code) embed = discord.Embed(description=f"```css\n{shell}```") - embed.set_author(name="Shell", icon_url=self.bot.user.avatar_url) + embed.set_author(name="Shell", icon_url=ctx.me.avatar.with_format('png')) await msg.delete() await ctx.send(embed=embed) else: @@ -103,14 +103,13 @@ async def shell(self, ctx, *, code): @commands.command(pass_context=True) async def ping(self, ctx): - """Get Res's Ping""" t1 = time.perf_counter() - await ctx.trigger_typing() + await ctx.typing() t2 = time.perf_counter() ping = str(round((t2-t1)*1000)) - ol = round(ctx.bot.latencies[0][1]*1000) - sl = round(ctx.bot.latencies[1][1]*1000) - tl = round(ctx.bot.latencies[2][1]*1000) + ol = round(ctx.bot.latency * 1000) + sl = round(ctx.bot.latency * 1000) + tl = round(ctx.bot.latency * 1000) if ol >= 90: oe = '<:idle:701016198531383316>' else: @@ -126,9 +125,9 @@ async def ping(self, ctx): oc = await self.get_shard(1) sc = await self.get_shard(2) tc = await self.get_shard(3) - shard = ctx.guild.shard_id+1 - embed = discord.Embed(colour=0xa82021, description=f"The ping for **{ctx.guild.name}** is `{ping}ms`.") - embed.set_author(name="Pong!", icon_url=ctx.me.avatar_url_as(format='png')) + shard = ctx.guild.shard_id + 1 + embed = discord.Embed(colour=0x8980d9, description=f"The ping for **{ctx.guild.name}** is `{ping}ms`.") + embed.set_author(name="Pong!", icon_url=ctx.bot.user.avatar.url) embed.add_field(name=f"{oe} Shard #1", value=f"`{ol}ms` `{oc} servers`") embed.add_field(name=f"{se} Shard #2", value=f"`{sl}ms` `{sc} servers`") embed.add_field(name=f"{te} Shard #3", value=f"`{tl}ms` `{tc} servers`") @@ -137,10 +136,11 @@ async def ping(self, ctx): @commands.command() async def invite(self, ctx): - await ctx.send("Invite me to your server! ") + await ctx.send("Invite me to your server! ") @commands.command(hidden=True) async def load(self, ctx, extension): + print("\nLOAD INIT!\n") if ctx.author.id == 396153668820402197: try: if extension == 'all': @@ -150,7 +150,7 @@ async def load(self, ctx, extension): not_loaded = [] for extension in extensions: try: - self.bot.load_extension(extension) + await self.bot.load_extension(extension) loaded.append(f'`{extension}`') except Exception as error: not_loaded.append(f'`{extension}` - `{error}`') @@ -164,13 +164,13 @@ async def load(self, ctx, extension): embed.add_field(name='Not Loaded', value=not_loaded) await ctx.send(embed=embed) else: - self.bot.load_extension("cogs.{}".format(extension)) - embed = discord.Embed(title="<:CheckMark:473276943341453312> Cog loaded:", color=0x5bff69, description="**Cog:** `cogs\{}.py`".format(extension)) + await self.bot.load_extension("cogs.{}".format(extension)) + embed = discord.Embed(title="Cog loaded:", color=0x5bff69, description="<:CheckMark:473276943341453312> **Cog:** `cogs\\{}.py`".format(extension)) await ctx.send(embed=embed) print('\n\nCOG LOAD\n--[Cog loaded, {}.py]--\n\n'.format(extension)) except Exception as error: print('\n\nEXTEN./COG ERROR: {} was not loaded due to an error: \n-- [{}] --\n\n'.format(extension, error)) - embed = discord.Embed(title="<:WrongMark:473277055107334144> Error loading cog:", color=0xff775b, description="**Cog:** `cogs\{}.py`\n**Errors:**\n```{}```".format(extension, error)) + embed = discord.Embed(title="<:RedTick:653464977788895252> Error loading cog:", color=0xff775b, description="**Cog:** `cogs\\{}.py`\n**Errors:**\n```{}```".format(extension, error)) await ctx.send(embed=embed) else: pass @@ -178,8 +178,8 @@ async def load(self, ctx, extension): @commands.command(aliases=['un'], hidden=True) @commands.is_owner() async def unload(self, ctx, extension): - self.bot.unload_extension("cogs.{}".format(extension)) - embed = discord.Embed(title="<:CheckMark:473276943341453312> Cog unloaded:", color=0x5bff69, description="**Cog:** `cogs\{}.py`".format(extension)) + await self.bot.unload_extension("cogs.{}".format(extension)) + embed = discord.Embed(title="Cog unloaded:", color=0x5bff69, description="<:CheckMark:473276943341453312> **Cog:** `cogs\\{}.py`".format(extension)) print('\x1b[1;32;40m' + '[COG-RELOADED]: ' + '\x1b[0m' + '{} was unloaded successfully'.format(extension)) await ctx.send(embed=embed) @@ -188,14 +188,16 @@ async def unload(self, ctx, extension): async def reload(self, ctx, extension): if ctx.author.id == 396153668820402197: try: - self.bot.unload_extension("cogs.{}".format(extension)) - self.bot.load_extension("cogs.{}".format(extension)) - embed = discord.Embed(title="<:CheckMark:473276943341453312> Cog reloaded:", color=0x5bff69, description="**Cog:** `cogs\{}.py`".format(extension)) + await ctx.typing() + await self.bot.unload_extension("cogs.{}".format(extension)) + await asyncio.sleep(1) + await self.bot.load_extension("cogs.{}".format(extension)) + embed = discord.Embed(title="Cog reloaded:", color=0x5bff69, description="<:CheckMark:473276943341453312> **Cog:** `cogs\\{}.py`".format(extension)) await ctx.send(embed=embed) print('\x1b[1;32;40m' + '[COG-RELOADED]: ' + '\x1b[0m' + '{} was reloaded successfully'.format(extension)) except Exception as error: print('\x1b[1;31;40m' + '[COG-RELOAD-ERROR]: ' + '\x1b[0m' + '{} was not reloaded due to an error: {} '.format(extension, error)) - embed = discord.Embed(title="<:WrongMark:473277055107334144> Error reloading cog:", color=0xff775b, description="**Cog:** `cogs\{}.py`\n**Errors:**\n```{}```".format(extension, error)) + embed = discord.Embed(title="<:RedTick:653464977788895252> Error reloading cog:", color=0xff775b, description="**Cog:** `cogs\\{}.py`\n**Errors:**\n```{}```".format(extension, error)) await ctx.send(embed=embed) else: pass @@ -216,17 +218,19 @@ async def on_command_error(self, ctx, error): # <:RedTick:653464977788895252> await ctx.send(f"<:RedTick:653464977788895252> You are on cooldown! Please wait **{hours} {round(minutes)}m {round(seconds)}s**.") else: + id = ''.join([random.choice(string.digits) if i % 2 == 0 else random.choice(string.ascii_letters) for i in range(7)]) print("\x1b[1;31;40m" + f"[{type(error).__name__}]: " + "\x1b[0m" + str(error)) - ig = (asyncio.futures.TimeoutError, commands.CommandNotFound, commands.CommandOnCooldown, discord.Forbidden, commands.NoPrivateMessage, commands.DisabledCommand, commands.CheckFailure, commands.UserInputError) + ig = (TimeoutError, commands.CommandNotFound, commands.CommandOnCooldown, discord.Forbidden, commands.NoPrivateMessage, commands.DisabledCommand, commands.CheckFailure, commands.UserInputError) error = getattr(error, 'original', error) if isinstance(error, ig): return - embed = discord.Embed(colour=0xa82021) - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Command Error") + embed = discord.Embed(colour=0xff0000) + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Command Error") embed.set_footer(text=f"Type: {type(error).__name__.upper()}") description = f"**Command**: {ctx.command.qualified_name}\n"\ f"**Author**: {ctx.author} `ID: {ctx.author.id}`\n"\ - f"**Channel**: #{ctx.channel} `ID: {ctx.channel.id}`" + f"**Channel**: #{ctx.channel} `ID: {ctx.channel.id}`\n"\ + f"**Error ID:** {id}" if ctx.guild: description += f'\n**Guild**: {ctx.guild} `ID: {ctx.guild.id}`' fe = ''.join(traceback.format_exception(type(error), error, error.__traceback__, chain=False)) @@ -241,6 +245,7 @@ async def on_command_error(self, ctx, error): # <:RedTick:653464977788895252> pass try: await self.bot.get_channel(658708974836645888).send(embed=embed) + await ctx.send(f"<:RedTick:653464977788895252> Error! Please see our [Support Server](https://discord.gg/BCRtw7c) for more information. `Code: {id}`") except: pass if isinstance(error, commands.CommandInvokeError): @@ -251,4 +256,5 @@ async def on_command_error(self, ctx, error): # <:RedTick:653464977788895252> async def setup(bot): - await bot.add_cog(Botdev(bot)) + cog = Botdev(bot) + await bot.add_cog(cog) diff --git a/cogs/btn-example.py b/cogs/btn-example.py new file mode 100644 index 0000000..eba1fb9 --- /dev/null +++ b/cogs/btn-example.py @@ -0,0 +1,25 @@ + + + async def button_callback(interaction): + await interaction.response.defer() + + + + button = Button(label="←", custom_id="prev_page", style=discord.ButtonStyle.primary) + + + d_btn.callback = lambda interaction: t_button_callback(interaction, "d", b) + + view = View() + view.add_item(button) + + # no args + button.callback = button_callback + + + if msg: + await food_msg.delete() + try: + await interaction.message.delete() + except: + pass \ No newline at end of file diff --git a/cogs/cookoff.py b/cogs/cookoff.py new file mode 100644 index 0000000..f302412 --- /dev/null +++ b/cogs/cookoff.py @@ -0,0 +1,414 @@ +import discord +from discord.ext import commands, tasks +import datetime +import random +import math +import time +from discord.ext.commands import errors, converter +from random import randint, choice as rnd +import asyncio +import json +import os +import config +from pymongo import MongoClient +import pymongo +import string +import requests +import motor.motor_asyncio +import trivia +import awards +from discord.ui import View, Button + +client = motor.motor_asyncio.AsyncIOMotorClient(config.mongo_client) +db = client['siri'] + +bbux = "<:BistroBux:1324936072760786964>" + +class Cookoff(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.game_jmsg = None + self.contest_msg = None + self.gamestart_msg = None + self.players = {} + self.bet_amount = 0 + self.game_host = None + + @commands.group(aliases=['Cookoff', 'cookoff']) + @commands.cooldown(1, 3, commands.BucketType.user) + async def contest(self, ctx): + if ctx.invoked_subcommand is None: + post = await db.market.find_one({"owner": ctx.author.id}) + if post: + embed = discord.Embed(colour=0x8980d9, description=f"Welcome to **Bistro Cook-Off**!\n\nThis is your chance to show the world what you're made of! " + f"Play with up to 3 other people. You can bet up to {bbux}50, and the winner takes it all. Once started, you will play three minigame rounds in your DMs." + "\n\nWanna give it a go? Hit `Create Game` below to start a game.") + embed.set_image(url="https://media.discordapp.net/attachments/1325282246181130330/1329331828859076622/phonto.png?ex=6789f43d&is=6788a2bd&hm=7edc4d7b1d8874a61022a15dd74aba7201d6f516fa2b9f9374e0145d7a01484d&=&format=webp&quality=lossless&width=2160&height=462") + view = pageBtns(self) + self.contest_msg = await ctx.send(embed=embed, view=view) + else: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.start`") + + @contest.command(aliases=['Cookoff', 'cookoff']) + @commands.cooldown(1, 3, commands.BucketType.user) + async def start(self, ctx): + if not self.game_jmsg: + await ctx.send("<:RedTick:653464977788895252> There is no game to start! Start one with `b.cookoff`") + return + elif ctx.author.id != self.game_host: + await ctx.send("<:RedTick:653464977788895252> Only the host can start the game!") + return + elif len(self.players) < 2: + await ctx.send("<:RedTick:653464977788895252> Not enough players! You need at least 2 players to start the game.") + return + + embed = discord.Embed(colour=0x8980d9, description=f"The game starts in 15 seconds!\n\n **Players:**\n * {'\n* '.join([str(ctx.guild.get_member(player_id).name) for player_id in self.players])}") + embed.set_footer(text="The game will start in your DMs soon!") + await self.game_jmsg.delete() + self.gamestart_msg = await ctx.send(embed=embed) + await asyncio.sleep(5) + await self.start_game(ctx) + + async def start_game(self, ctx): + tasks = [] + for player_id in self.players: + player = ctx.guild.get_member(player_id) + self.players[player_id] = {"points": 0} + await self.take_money(user=player_id, count=self.bet_amount) + if player: + post = await db.market.find_one({"owner": player.id}) + tasks.append(self.ask_questions(ctx, player)) + + await asyncio.gather(*tasks) + await asyncio.sleep(2) + await self.determine_winner(ctx) + + async def ask_questions(self, ctx, player): + post = await db.market.find_one({"owner": player.id}) + player_id = player.id + await player.send("The game is starting in 10 seconds. Get ready!") + await asyncio.sleep(10) + word = rnd(post['items'])['name'] + ws = word.split(" ") + new = [] + for x in ws: + li = list(x) + random.shuffle(li) + sw = "".join(li) + new.append(sw) + sw = " ".join(new) + na = word + embed = discord.Embed(colour=0x8980d9, description=f"Unscramble this item on your menu to start making it: `{sw}`") + embed.set_footer(text=f"Round 1 | Points: {self.players[player_id]["points"]}") + await player.send(embed=embed) + b = time.perf_counter() + try: + resp = await self.bot.wait_for('message', check=lambda m: m.author == player, timeout=20) + a = time.perf_counter() + tt = a-b + round_one_pts = 0 + if tt <= 4: + if resp.content.lower() == word.lower(): + round_one_pts = 100 + else: + round_one_pts = 20 + elif tt < 7: + if resp.content.lower() == word.lower(): + round_one_pts = 90 + else: + round_one_pts = 15 + elif tt < 10: + if resp.content.lower() == word.lower(): + round_one_pts = 80 + else: + round_one_pts = 10 + elif tt < 13: + if resp.content.lower() == word.lower(): + round_one_pts = 70 + else: + round_one_pts = 0 + else: + if resp.content.lower() == word.lower(): + round_one_pts = 20 + else: + round_one_pts = 0 + if resp.content.lower() == word.lower(): + await player.send(f"You answered correctly and earned **{round_one_pts} points**! Get ready for the next one...") + else: + await player.send(f"You answered incorrectly and earned **{round_one_pts} points**! Get ready for the next one...") + except asyncio.TimeoutError: + await player.send("You took too long to answer and earned **0 points**!") + round_one_pts = 0 + self.players[player_id]["points"] += round_one_pts + await player.typing() + await asyncio.sleep(3) + bar_int = 0 + country = post['country'] + flist = None + if word.endswith("s"): + cfooda = "the " + word + else: + if word.startswith(("a", "e", "i", "o", "u")): + cfooda = "an " + word + else: + cfooda = "a " + word + + done = False + desc = f"Let's finish making {cfooda}!\n\nClick `stop` when the bar gets to red.\n\n`🟨`" + embed = discord.Embed(description=desc) + embed.set_footer(text=f"Round 2 | Points: {self.players[player_id]["points"]}") + button = Button(label="Stop", style=discord.ButtonStyle.red) + view = View() + view.add_item(button) + round_two_pts = 0 + desc2 = "" + async def button_callback(interaction): + nonlocal done, bar_int, bar, desc2, round_two_pts + if interaction.user == player: + await interaction.response.defer() + done = True + if bar_int > 5: + desc2 = f"You left {cfooda} going for too long!" + round_two_pts = 0 + elif bar_int == 5: + desc2 = f"You made {cfooda} perfectly!" + round_two_pts = 100 + elif bar_int == 4: + desc2 = f"You almost made {cfooda} perfectly!" + round_two_pts = 80 + else: + desc2 = f"You undercooked {cfooda}!" + round_two_pts = 40 + + button.callback = button_callback + msg = await player.send(embed=embed, view=view) + await asyncio.sleep(1) + while bar_int <= 6 and not done: + bar_int += 1 + bar = str(bar_int).replace("7", "`🟨🟨🟧🟧🟥⬛`").replace("6", "`🟨🟨🟧🟧🟥⬛`").replace("5", "`🟨🟨🟧🟧🟥`").replace("4", "`🟨🟨🟧🟧`").replace("3", "`🟨🟨🟧`").replace("2", "`🟨🟨`").replace("1", "`🟨`") + embed = discord.Embed(description=f"Let's finish making {cfooda}!\n\nClick `stop` when the bar gets to red.\n\n{bar}") + if bar_int == 7: + desc2 = f"You left {cfooda} going for too long!" + round_two_pts = 0 + done = True + elif bar_int > 5: + embed.color = 0x000000 + embed.set_footer(text=f"This isn't going well!") + elif bar_int == 5: + embed.color = 0xfc2121 + elif bar_int == 3 or bar_int == 4: + embed.color = 0xfa8c16 + else: + embed.color = 0xf9ff40 + embed.set_footer(text=f"You're making {cfooda}.") + + await msg.edit(embed=embed) + await asyncio.sleep(0.6) + if not done: + desc2 = f"You left {cfooda} going for too long!" + round_two_pts = 0 + done = True + await player.send(f"{desc2} You received **{round_two_pts} points**. Last question is coming...") + try: + await msg.delete() + except: + pass + self.players[player_id]["points"] += round_two_pts + await player.typing() + await asyncio.sleep(3) + embed = discord.Embed(colour=0x8980d9) + footer = None + question = rnd(trivia.questions) + letters = ["a", "b", "c", "d"] + cn = 0 + desc = "" + choices = [] + for x in question['answers']: + cn += 1 + if cn == 1: + choices.append({"a":question['answers'][0], "letter": "a"}) + elif cn == 2: + choices.append({"b":question['answers'][1], "letter": "b"}) + elif cn == 3: + choices.append({"c":question['answers'][2], "letter": "c"}) + else: + choices.append({"d":question['answers'][3], "letter": "d"}) + opt = [] + for x in choices: + letter = x['letter'] + opt.append(f":regional_indicator_{x['letter']}: {x[letter]}") + answers = "\n".join(opt) + embed.description = "*What's a Cook Off without **trivia**?*\n\n**" + question['question'] + "**\n\n" + answers + embed.set_footer(text="You have 25 seconds to respond with the correct letter.") + await player.send(embed=embed) + cl = None + for x in choices: + letter = x['letter'] + if x[letter] == question['correct']: + cl = x['letter'] + b = time.perf_counter() + try: + msg = await self.bot.wait_for('message', check=lambda x: x.author == player, timeout=25) + a = time.perf_counter() + tc = a-b + if msg.content.lower() == cl or msg.content.lower() == question['correct'].lower(): + wrong = False + if tc <= 6: + round_three_pts = 100 + resp3 = "You've answered correctly in under 6 seconds!" + elif tc <= 10: + round_three_pts = 80 + resp3 = "You've answered correctly in under 10 seconds!" + elif tc <= 15: + round_three_pts = 60 + resp3 = "You've answered correctly in under 15 seconds!" + else: + round_three_pts = 40 + resp3 = "You've answered correctly!" + else: + wrong = True + if wrong: + resp3 = "You've answered incorrectly!" + round_three_pts = 0 + except asyncio.TimeoutError: + round_three_pts = 0 + resp3 = "You didn't answer in time!" + await player.send(f"{resp3} You've earned {round_three_pts} points. Finalizing results...") + await player.typing() + self.players[player_id]["points"] += round_three_pts + await asyncio.sleep(3) + embed = discord.Embed(colour=0x8980d9, description=f"Your results...\n\n**Round 1**: {round_one_pts}\n**Round 2**: {round_two_pts}\n**Round 3**: {round_three_pts}\n\n**TOTAL**: {self.players[player_id]['points']} Points") + embed.set_footer(text="Winner is being calculated! Check back in the discord server for the final result.") + await player.send(embed=embed) + + + async def determine_winner(self, ctx): + winner_id = max(self.players, key=lambda player_id: self.players[player_id]["points"]) + winner = ctx.guild.get_member(winner_id) + player_amnt = len(self.players) + amnt_given = player_amnt * self.bet_amount + await winner.send(f"Congratulations, you have won the Cook Off! You've been awarded {bbux}{amnt_given}.") + await self.add_money(user=winner.id, count=amnt_given) + sorted_players = sorted(self.players.items(), key=lambda x: x[1]["points"], reverse=True) + description = f"The winner of the Cook Off is **{winner.name}** with {self.players[winner_id]['points']} points!\n\n**Leaderboard**:\n" + place = 1 + for player_id, points in sorted_players: + player = ctx.guild.get_member(player_id) + description += f"`#{place}` **{player.name}** - {points['points']} points\n" + place += 1 + + embed = discord.Embed(colour=0x8980d9, description=description+ "\n\nThanks for playing!") + embed.set_image(url="https://media.discordapp.net/attachments/1325282246181130330/1329331828859076622/phonto.png?ex=6789f43d&is=6788a2bd&hm=7edc4d7b1d8874a61022a15dd74aba7201d6f516fa2b9f9374e0145d7a01484d&=&format=webp&quality=lossless&width=2160&height=462") + await ctx.send(embed=embed) + try: + await self.gamestart_msg.delete() + except: + pass + await asyncio.sleep(1) + await self.clear_game() + + async def clear_game(self): + self.game_jmsg = None + self.gamestart_msg = None + self.players.clear() + self.game_host = None + self.bet_amount = 0 + + @contest.command(aliases=['Join']) + async def join(self, ctx): + post = await db.market.find_one({"owner": ctx.author.id}) + if not post: + await ctx.send("<:RedTick:653464977788895252> You cannot join without having a restaurant! Create one with `b.start`") + if not self.game_jmsg: + await ctx.send("<:RedTick:653464977788895252> There is no game to join!") + return + if ctx.author.id in self.players: + await ctx.send("<:RedTick:653464977788895252> You're already in this game!") + return + if len(self.players) >= 4: + await ctx.send("<:RedTick:653464977788895252> The game is already full! You cannot join.") + return + if post['money'] < self.bet_amount: + await ctx.send("<:RedTick:653464977788895252> You cannot join because you don't have enough money to bet!") + if self.gamestart_msg: + await ctx.send(f"<:RedTick:653464977788895252> The game has already started!") + + self.players[ctx.author.id] = {"points": 0} + host = ctx.guild.get_member(self.game_host) + + embed = discord.Embed(colour=0x8980d9, description=f"Welcome to **Cook Off**!\n\n2 players are necessary to start the game. To join, type `b.cookoff join` and the bet will be taken from your balance.\n" \ + f"The host, **{host.name}**, can start the game with `b.cookoff start` or cancel it with `b.cookoff cancel`\n\n" \ + f"**Bet**: `{self.bet_amount}`\n**Stake**: `{self.bet_amount*len(self.players)}`\n**Players Joined**: `{len(self.players)}/4`\n* " + '\n* '.join([str(ctx.guild.get_member(player_id).name) for player_id in self.players])) + embed.set_footer(text=f"Waiting on {host.name} to start the game...") + await self.game_jmsg.edit(embed=embed) + try: + await ctx.message.delete() + except: + pass + + + @contest.command(aliases=['cancel']) + async def cancel_game(self, ctx): + if ctx.author.id != self.game_host: + await ctx.send("<:RedTick:653464977788895252> Only the host can cancel the game!") + return + await self.clear_game() + await ctx.send("<:CheckMark:473276943341453312> The game has been canceled by the host.") + if self.game_jmsg: + await self.game_jmsg.delete() + + async def add_money(self, user:int, count): + data = await db.market.find_one({"owner": user}) + bal = data['money'] + money = int(bal) + count + await db.market.update_one({"owner": user}, {"$set":{"money": money}}) + if data['money'] >= 500 and not 'fivehundred_bbux' in data['awards']: + award = await self.get_award(user, "fivehundred_bbux") + elif data['money'] >= 1500 and not 'thousand_bbux' in data['awards']: + award = await self.get_award(user, "thousand_bbux") + elif data['money'] >= 3000 and not 'twothousand_bbux' in data['awards']: + award = await self.get_award(user, "twothousand_bbux") + + async def take_money(self, user:int, count:int): + data = await db.market.find_one({"owner": user}) + bal = data['money'] + money = int(bal) - count + await db.market.update_one({"owner": user}, {"$set":{"money": money}}) + + +class pageBtns(discord.ui.View): + def __init__(self, cog): + super().__init__(timeout=None) + self.cog = cog + + @discord.ui.button(label="Create Game", style=discord.ButtonStyle.primary) + async def create_game(self, interaction: discord.Interaction, button: discord.ui.Button): + def ans(m): + return m.author == interaction.user + await self.cog.contest_msg.delete() + post = await db.market.find_one({"owner": interaction.user.id}) + embed = discord.Embed(colour=0x8980d9, description=f"{interaction.user.mention}, so you wanna play a round, huh? What do you want the bet to be? You can pick anything from {bbux}5 to {bbux}50.") + embed.set_footer(text="You have 20 seconds to respond with a number.") + count_msg = await interaction.channel.send(embed=embed) + count = await interaction.client.wait_for('message', check=ans, timeout=20) + + try: + await count_msg.delete() + await count.delete() + except: + pass + + if count.content.isdigit() and 5 <= int(count.content) <= 50: + self.cog.bet_amount = int(count.content) + embed = discord.Embed(colour=0x8980d9, description=f"Welcome to **Cook Off**!\n\n2 players are necessary to start the game. To join, type `b.cookoff join` and the bet will be taken from your balance.\n" \ + f"The host, **{interaction.user.name}**, can start the game with `b.cookoff start` or cancel it with `b.cookoff cancel`\n\n" \ + f"**Bet**: `{count.content}`\n**Stake**: `{self.cog.bet_amount}`\n**Players Joined**: `1/4`\n\n **(1)** {interaction.user.name}") + embed.set_footer(text=f"Waiting on {interaction.user} to start the game...") + self.cog.game_jmsg = await interaction.channel.send(embed=embed) + self.cog.players[interaction.user.id] = {"points": 0} + self.cog.game_host = interaction.user.id + else: + await interaction.channel.send(f"<:RedTick:653464977788895252> The bet must be a number between {bbux}5 and {bbux}50. Restart the process with `b.cookoff`") + +async def setup(bot): + await bot.add_cog(Cookoff(bot)) diff --git a/cogs/dbl.py b/cogs/dbl.py deleted file mode 100644 index 0acd766..0000000 --- a/cogs/dbl.py +++ /dev/null @@ -1,14 +0,0 @@ -import dbl -import discord -from discord.ext import commands -import config - -class TopGG(commands.Cog): - - def __init__(self, bot): - self.bot = bot - self.dblpy = dbl.DBLClient(self.bot, config.dbl_token, autopost=True) - - -async def setup(bot): - await bot.add_cog(TopGG(bot)) diff --git a/cogs/dev.py b/cogs/dev.py index f5daa36..914f5f5 100644 --- a/cogs/dev.py +++ b/cogs/dev.py @@ -29,7 +29,7 @@ class Dev(commands.Cog): def __init__(self, bot): self.bot = bot - self.prefix = 'r!' + self.prefix = 'b.' self.process = psutil.Process(os.getpid()) self.rs = [] self._last_result = None @@ -63,9 +63,9 @@ async def message(self, ctx, *, message=None): await log.send(embed=embed) await ctx.send("Success! Your message has been sent to support. You should expect a message in your DMs when we get the chance! If you are reporting a serious bug, or having anymore questions, join the support server: ") - @commands.command(aliases=['Stats', 'info', 'botinfo', 'status']) + @commands.command(aliases=['Info', 'botinfo', 'status']) @commands.cooldown(1, 2, commands.BucketType.user) - async def stats(self, ctx): + async def info(self, ctx): users = len(set(self.bot.get_all_members())) channels = [] @@ -80,31 +80,42 @@ async def stats(self, ctx): ram = self.process.memory_full_info().rss / 1024**2 - stat = discord.Embed(colour=0xa82021, description=f"**Restaurant** `by lukee#0420`\n\n\n" \ - f"\> **Python**... `3.6`\n" \ - f"\> **Ubuntu**... `18.04`\n" \ - f"\> **RAM Usage**... `{ram:.2f}MB`\n\n" + stat = discord.Embed(colour=0x8980d9, description=f"**Bistro** `by paixlukee`\n\n\n"\ + f"\\> **Python**... `3.2`\n"\ + f"\\> **Ubuntu**... `22`\n"\ + f"\\> **RAM Usage**... `{ram:.2f}MB`\n\n"\ f"I am in **{str(len(self.bot.guilds))} servers**!\n"\ f"I can view **{channels} channels**!\n"\ f"I am with **{users} users**!\n"\ f"I can use **{emojis} emojis**!\n\n"\ - f"[[Invite]](https://discordapp.com/api/oauth2/authorize?client_id=648065060559781889&permissions=8192&scope=bot)"\ + f"[[Invite]](https://discord.com/oauth2/authorize?client_id=657037653346222102&permissions=274878180416&integration_type=0&scope=bot)"\ f" [[Support]](https://discord.gg/BCRtw7c)") - stat.set_footer(text="Thanks for using Restaurant! | Res-V3") + stat.set_footer(text="Thanks for using Bistro! | Res-V4") await ctx.send(embed=stat) - @commands.command(aliases=['Prefix']) - @commands.cooldown(2, 120, commands.BucketType.user) + @commands.command(aliases=['Prefix', 'setprefix']) + @commands.cooldown(2, 20, commands.BucketType.user) async def prefix(self, ctx, prefix=None): - cp = "r!" + cp = "b." + await ctx.typing() + current = db.utility.find_one({"utility": "prefixes", "prefixes.guild": ctx.guild.id}) if ctx.author.guild_permissions.manage_guild: if not prefix: await ctx.send("<:RedTick:653464977788895252> You need to include a prefix! Example: `{cp}prefix ?`") elif len(prefix) > 4: await ctx.send("<:RedTick:653464977788895252> Prefix can't be longer than 4 characters!") + elif current: + if prefix == 'b.': + await ctx.send("<:CheckMark:1330789181470937139> Prefix reset.") + db.utility.update_one({"utility": "prefixes", "prefixes.guild": ctx.guild.id}, {"$pull": {"prefixes": {"guild": ctx.guild.id}}}) + else: + db.utility.update_one({"utility": "prefixes", "prefixes.guild": ctx.guild.id}, {"$set": {"prefixes.$.prefix": prefix}}) + await ctx.send(f"<:CheckMark:1330789181470937139> BistroBot Prefix set! To reset it, do `{prefix}prefix {cp}`") + elif prefix == 'b.': + await ctx.send(f"<:RedTick:653464977788895252> That is the standard prefix of BistroBot!") else: db.utility.update_one({"utility": "prefixes"}, {"$push": {"prefixes": {"guild": ctx.guild.id, "prefix": prefix}}}) - await ctx.send(f"Restaurant Prefix set! To change it back, do `{prefix}prefix {cp}`") + await ctx.send(f"<:CheckMark:1330789181470937139> BistroBot Prefix set! To change it back, do `{prefix}prefix {cp}`") else: await ctx.send("<:RedTick:653464977788895252> You need `manage_server` permissions to change the server prefix!") @@ -112,16 +123,16 @@ async def prefix(self, ctx, prefix=None): async def patron(self, ctx, user_id:int, tier='BRONZE'): if ctx.author.id == 396153668820402197: db.utility.update_one({"utility": "patrons"}, {"$push":{tier.lower(): user_id}}) - if tier.lower() == "gold": - db.market.update_one({"owner": user_id}, {"$push": {"inventory":{"banner": {"name": "Gold Patron", "url": "http://paixlukee.ml/m/MKAKZ.png", 'rarity': 'Legendary'}}}}) - elif tier.lower() == "diamond": - db.market.update_one({"owner": user_id}, {"$push": {"inventory":{"banner": {"name": "Diamond Patron", "url": "http://paixlukee.ml/m/S1L2D.png",'rarity': 'Legendary'}}}}) - else: + if tier.lower() == "diamond": + await self.add_rand_fragment(ctx.author.id, all=True) + + user = await self.bot.fetch_user(user_id) + await ctx.send(f"<:CheckMark:1330789181470937139> **{str(user)}** is now a patron in the **{tier.upper()}** tier! Hell yeah!") + embed = discord.Embed(colour=0x8980d9, title="Thanks!", description="Woah! Thank you so so so much for your patronage!\n\nAll of the rewards have been applied to your account. All tiers and information on them are listed [here](https://www.patreon.com/join/paixlukee).") + try: + await user.send(embed=embed) + except: pass - user = self.bot.fetch_user(user_id) - await ctx.send(f"**{user.display_name}** is now a patron in the **{tier.upper()}** tier! Hell yeah!") - embed = discord.Embed(colour=0xa82021, title="Thanks!", description="Woah! Thank you so so so much for your patronage!\n\nAll the rewards have been applied to your account. All tiers and information on them are listed [here](https://www.patreon.com/join/paixlukee).") - await user.send(embed=embed) else: pass @@ -129,8 +140,8 @@ async def patron(self, ctx, user_id:int, tier='BRONZE'): async def unpatron(self, ctx, user_id:int, tier='BRONZE'): if ctx.author.id == 396153668820402197: db.utility.update_one({"utility": "patrons"}, {"$pull":{tier.lower(): user_id}}) - user = self.bot.fetch_user(user_id) - await ctx.send(f"**{user.display_name}** is no longer a patron in the **{tier.upper()}** tier. :(") + user = await self.bot.fetch_user(user_id) + await ctx.send(f"**{str(user)}** is no longer a patron in the **{tier.upper()}** tier. :(") else: pass @@ -142,16 +153,16 @@ async def patrons(self, ctx): gold = [] diamond = [] for x in patrons['bronze']: - user = self.bot.fetch_user(x) + user = await ctx.guild.fetch_member(x) bronze.append(f"{user.display_name} - {user.id}") for x in patrons['silver']: - user = self.bot.fetch_user(x) + user = await ctx.guild.fetch_member(x) silver.append(f"{user.display_name} - {user.id}") for x in patrons['gold']: - user = self.bot.fetch_user(x) + user = await ctx.guild.fetch_member(x) gold.append(f"{user.display_name} - {user.id}") for x in patrons['diamond']: - user = self.bot.fetch_user(x) + user = await ctx.guild.fetch_member(x) diamond.append(f"{user.display_name} - {user.id}") embed = discord.Embed(description="Listed are users patronising:") if bronze: @@ -216,7 +227,7 @@ async def eval(self, ctx, *, code): self._last_result = result if code == "bot.http.token": - embed=discord.Embed(colour=0xa82021, description=f":inbox_tray: **INPUT**:\n```py\n{code}```\n:outbox_tray: **OUTPUT**:\n```py\n{result}```") + embed=discord.Embed(colour=0x8980d9, description=f":inbox_tray: **INPUT**:\n```py\n{code}```\n:outbox_tray: **OUTPUT**:\n```py\n{result}```") return await ctx.send(embed=embed) elif o_code.endswith(" -silent") or o_code.endswith(" -s"): @@ -228,7 +239,7 @@ async def eval(self, ctx, *, code): return await ctx.send(":weary::ok_hand: The output is too long to send to chat. Here is a hastebin file for ya.. :point_right: https://hastebin.com/" + r['key']) else: try: - embed=discord.Embed(colour=0xa82021, description=f":inbox_tray: **INPUT**:\n```py\n\u200b{code}```\n:outbox_tray: **OUTPUT**:\n```py\n{result}```") + embed=discord.Embed(colour=0x8980d9, description=f":inbox_tray: **INPUT**:\n```py\n\u200b{code}```\n:outbox_tray: **OUTPUT**:\n```py\n{result}```") return await ctx.send(embed=embed) except Exception as e: embed=discord.Embed(colour=0xff0000, description=f":inbox_tray: **INPUT**:\n```py\n{code}```\n:outbox_tray: **OUTPUT**:\n```py\n{e}```") @@ -240,6 +251,24 @@ async def eval(self, ctx, *, code): return await ctx.send(embed=embed) else: pass + + async def add_rand_fragment(self, user, all=False): + post = db.market.find_one({"owner": user}) + fragments = ['agility', 'opportunity', 'endearing', 'ambience'] + exclude = post['stones'] + if all: + for fragment in fragments: + if fragment in exclude: + continue + in_list = False + for frag in post['fragments']: + if frag['stone'] == fragment: + db.market.update_one({"owner": user, "fragments.stone": fragment},{"$inc": {"fragments.$.count": 1}}) + in_list = True + break + if not in_list: + db.market.update_one({"owner": user}, {"$push": {"fragments": {"stone": fragment, "count": 1}}}) + return True diff --git a/cogs/drops.py b/cogs/drops.py index ccb7d75..4ca6441 100644 --- a/cogs/drops.py +++ b/cogs/drops.py @@ -33,7 +33,6 @@ async def loot(self): servers = lb['guilds'] ntp = [] ntp_g = [] - # {"gid": 0, "cid": 0, "opened_last": bool} for x in servers: if opened_last is True: ntp.append(x['cid']) diff --git a/cogs/help.py b/cogs/help.py index d9825b0..de6a8f8 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -15,132 +15,125 @@ import config from pymongo import MongoClient import pymongo +from discord.ui import View, Button client = MongoClient(config.mongo_client) db = client['siri'] async def get_pre(bot, message): posts = db.utility.find_one({"utility": "prefixes"}) - pref = "r!" + pref = "b." for x in posts['prefixes']: if x['guild'] == message.guild.id: pref = x['prefix'] return pref + + class Help(commands.Cog): def __init__(self, bot): self.bot = bot - @commands.command(aliases=['V2']) - async def v2(self, ctx): - description = "Introducing... **Res V2**\n\n"\ - "I am so glad we made it so far... 1.2k servers! I hope you enjoy this update and updates yet to come. Now here are the changes...!\n\n"\ - "__**New Commands:**__\n"\ - "`r!hire` - Hire an employee to help you work!\n"\ - "`r!worker` - Manage your employee\n"\ - "`r!discoin` - Manage discoin transactions\n\n"\ - "*Wait... what's discoin?* To put it into simple terms... Its a way to convert restaurant currency to currency on others bots! To view available currencies, do `r!discoin bots`.\n\n"\ - "__**Command Changes**__\n"\ - "- Beg command cooldown is now 90 seconds instead of 60 seconds\n"\ - "- Work command is now 7 minutes instead of 8 minutes\n"\ - "- There are 8 new colours, 6 new banners, 7 new trivia questions, and 3 new work responses\n\n"\ - "__**Style Changes**__\n"\ - "- New banner for help command\n"\ - "- Links have been put onto the help command\n"\ - "- Emoji \"<:RedTick:653464977788895252>\" has been added to all error messages\n\n"\ - "__**Bug Fixes**__\n"\ - "- Fixed an error that would stop cooldowns from resetting on some errors\n"\ - "- Fixed an error where sometimes the `r!daily` command wouldn't give you any money.\n" - embed = discord.Embed(description=description) - embed.set_footer(text="from lukee#0420", icon_url="https://images-ext-2.discordapp.net/external/_ULuCbUCIqYZnsc6J04zIVeuKvDhm6HlCxF6ZU0v338/%3Fsize%3D256%26f%3D.gif/https/cdn.discordapp.com/avatars/396153668820402197/a_802dfb76b03607e983c0dd7b171aa3d8.gif") - await ctx.send(embed=embed) - @commands.group(aliases=['cmds', 'commands', 'Help', 'h', '?']) async def help(self, ctx, page=None): #keeping this hardcoded, because it will only make me do more work :) - post = db.market.find_one({"owner": ctx.author.id}) - pre = await get_pre(ctx.bot, ctx.message) - try: - page = int(page.lower().replace("#", "").replace("page", "")) - except: - pass - pages = [1,2,3,4] - if not page or not page in pages: - if not post: - an = "It seems that you don't have a restaurant, do `r!start` to make one." - else: - an = "" - embed = discord.Embed(colour=0xa82021, description=f"Welcome! Here is a list of commands that you are able to use. {an}") - embed.add_field(name="Page #1 | Restaurant", value="The main restaurant commands.") - embed.add_field(name="Page #2 | User", value="Commands that interact with regular users.") - embed.add_field(name="Page #3 | Inventory", value="Buy, use, and view items in your inventory.") - embed.add_field(name="Page #4 | Bot", value="Commands that have to do with the main bot.") - #embed.add_field(name="EVENT! | Halloween", value="`r!eventinfo`\n`r!halloween`") - embed.add_field(name="Links", value="[DBL](https://top.gg/bot/648065060559781889)\n[Donate](https://www.patreon.com/paixlukee)\n[Support Server](http://discord.gg/BCRtw7c)") - #embed.add_field(name="Page #4 | Configuration", value="Configurate guild-only settings,") - embed.set_author(icon_url=ctx.me.avatar.with_format('png'), name="Restaurant Help Manual") - embed.set_image(url="http://paixlukee.dev/m/SUG3O.png")#reg: http://paixlukee.dev/m/FGGUC.png") - embed.set_footer(text="To view a page, put the page number right after the command. Example: r!help 1") - await ctx.send(embed=embed) - elif page == 1: - embed = discord.Embed(colour=0xa82021, description="The main restaurant commands.") - embed.add_field(name=f"{pre}start", value="Create your restaurant") - embed.add_field(name=f"{pre}restaurant [restaurant]", value="View your own restaurant") - embed.add_field(name=f"{pre}rate <@user>", value="Rate a restaurant") - embed.add_field(name=f"{pre}menu ", value="View a restaurant menu") - embed.add_field(name=f"{pre}set", value="Configurate your restaurant settings") - embed.add_field(name=f"{pre}daily", value="Receive your daily cash") - embed.add_field(name=f"{pre}work", value="Work at your restaurant and receive money") - embed.add_field(name=f"{pre}beg", value="Beg the bank to give you a grant") - embed.add_field(name=f"{pre}clean", value="Clean your restaurant and receive EXP") - embed.add_field(name=f"{pre}cook", value="Cook an item and receive EXP") - embed.add_field(name=f"{pre}fish", value="Go fishing and get money & EXP. Your rod has 10% of breaking every use.") - embed.add_field(name=f"{pre}trivia", value="Play trivia and earn money.") - embed.add_field(name=f"{pre}leaderboard", value="View the global restaurant leaderboard") - embed.add_field(name=f"{pre}level", value="View level stats and how to level up.") - embed.add_field(name=f"{pre}hire", value="Hire an employee to help you work") - embed.add_field(name=f"{pre}worker", value="View how your employee is doing") - embed.set_author(icon_url=ctx.me.avatar.with_format('png'), name="Restaurant Help Manual | Page 1") - embed.set_image(url="http://paixlukee.dev/m/FGGUC.png") - embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the command.") - await ctx.send(embed=embed) - elif page == 2: - embed = discord.Embed(colour=0xa82021, description="Commands that interact with regular users.") - embed.add_field(name=f"{pre}profile [@user]", value="View a user profile") - embed.add_field(name=f"{pre}balance", value="View your balance") - embed.add_field(name=f"{pre}donate <@user> ", value="Donate money to someone else") - embed.add_field(name=f"{pre}dine ", value="Dine at a restaurant and gain EXP") - embed.add_field(name=f"{pre}donation", value="Donate to the bot") - embed.add_field(name=f"{pre}discoin", value="Manage discoin transactions") - embed.set_author(icon_url=ctx.me.avatar.with_format('png'), name="Restaurant Help Manual | Page 2") - embed.set_image(url="http://paixlukee.dev/m/FGGUC.png") - embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the command.") - await ctx.send(embed=embed) - elif page == 3: - embed = discord.Embed(colour=0xa82021, description="Buy, use, and view items in your inventory.") - embed.add_field(name=f"{pre}inventory", value="View your inventory") - embed.add_field(name=f"{pre}use ", value="Use or equip an item") - embed.add_field(name=f"{pre}buy", value="View shop and buy items") - embed.set_author(icon_url=ctx.me.avatar.with_format('png'), name="Restaurant Help Manual | Page 3") - embed.set_image(url="http://paixlukee.dev/m/FGGUC.png") - embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the command.") - await ctx.send(embed=embed) - elif page == 4: - embed = discord.Embed(colour=0xa82021, description="Commands that have to do with the main bot.") - embed.add_field(name=f"{pre}ping", value="View the ping") - embed.add_field(name=f"{pre}info", value="View information about Restaurant Bot") - embed.add_field(name=f"{pre}invite", value="Get the invite URL") - embed.add_field(name=f"{pre}prefix ", value="Set server prefix. (requires `manage_server` permissions)") - embed.add_field(name=f"{pre}patrons", value="View all of the current patrons") - embed.set_author(icon_url=ctx.me.avatar.with_format('png'), name="Restaurant Help Manual | Page 4") - embed.set_image(url="http://paixlukee.ml/m/FGGUC.png") - #embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the command.") - await ctx.send(embed=embed) - else: - pass + embed = discord.Embed(color=0x8980d9) + embed.set_image(url="https://media.discordapp.net/attachments/1325282246181130330/1325282279689289788/E46C7244-B665-48E2-B1A5-46A671413153.jpg?ex=677b38ce&is=6779e74e&hm=bd4d2f636a706e6a6aac44aec429884b1a121ff43d9f3f4d155238e14bbcd6af&=&format=webp&width=1140&height=1046") + embed.set_footer(text="Click a page number below to view it ") + view = pageBtns() + await ctx.send(embed=embed, view=view) + + + +class pageBtns(discord.ui.View): + def __init__(self): + super().__init__(timeout=None) + + self.add_item(discord.ui.Button(label="Support", url="https://discord.gg/BCRtw7c")) + self.add_item(discord.ui.Button(label="Donate", url="https://www.patreon.com/join/paixlukee")) + + @discord.ui.button(label="1", style=discord.ButtonStyle.primary) + async def page_1(self, interaction: discord.Interaction, button: discord.ui.Button): + bot = interaction.client + post = db.market.find_one({"owner": interaction.user.id}) + pre = await get_pre(bot, interaction.message) + embed = discord.Embed(colour=0x8980d9, description="The main restaurant commands.") + embed.add_field(name=f"{pre}start", value="Create your restaurant") + embed.add_field(name=f"{pre}restaurant [restaurant]", value="View a restaurant") + embed.add_field(name=f"{pre}rate <@user>", value="Rate a restaurant") + embed.add_field(name=f"{pre}menu ", value="View a restaurant menu") + embed.add_field(name=f"{pre}set", value="Configure your restaurant settings") + embed.add_field(name=f"{pre}daily", value="Receive your daily cash") + embed.add_field(name=f"{pre}work", value="Work at your restaurant and receive money") + embed.add_field(name=f"{pre}beg", value="Beg the bank to give you a grant") + embed.add_field(name=f"{pre}clean", value="Clean your restaurant and receive EXP") + embed.add_field(name=f"{pre}cook", value="Cook an item and receive EXP") + embed.add_field(name=f"{pre}fish", value="Go fishing and get money & EXP. Your rod has a chance of breaking per use.") + embed.add_field(name=f"{pre}trivia", value="Play trivia and earn money") + embed.add_field(name=f"{pre}slots", value="Use your income on a slot machine (Silver+ Patrons)") + embed.add_field(name=f"{pre}leaderboard [page | restaurant]", value="View the global Bistro leaderboard") + embed.add_field(name=f"{pre}hire", value="Hire an employee to help you work") + embed.add_field(name=f"{pre}workers", value="View how your employees are doing") + embed.add_field(name=f"{pre}adveArtise", value="Advertise your restaurant") + embed.add_field(name=f"{pre}cookoff", value="Start a cook-off with other players") + embed.add_field(name=f"{pre}event", value="Host an event") + embed.add_field(name=f"{pre}stones", value="View and fuse *Enhancement Stones*") + embed.set_author(icon_url=bot.user.avatar.with_format('png'), name="Bistro Help Manual | Page 1") + embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the actual command.") + await interaction.response.edit_message(embed=embed) + + + @discord.ui.button(label="2", style=discord.ButtonStyle.primary) + async def page_2(self, interaction: discord.Interaction, button: discord.ui.Button): + bot = interaction.client + post = db.market.find_one({"owner": interaction.user.id}) + pre = await get_pre(bot, interaction.message) + embed = discord.Embed(colour=0x8980d9, description="Commands that interact with regular users.") + embed.add_field(name=f"{pre}profile [@user]", value="View a user profile") + embed.add_field(name=f"{pre}balance", value="View your balance") + embed.add_field(name=f"{pre}stats", value="View all user & restaurant stats") + embed.add_field(name=f"{pre}awards", value="View your attainable rewards") + embed.add_field(name=f"{pre}level", value="View level stats and how to level up.") + embed.add_field(name=f"{pre}levelunlocks", value="View what each level unlocks") + embed.add_field(name=f"{pre}donate <@user> ", value="Donate money to another user") + embed.add_field(name=f"{pre}dine ", value="Dine at a restaurant and gain EXP") + embed.add_field(name=f"{pre}donation", value="Donate to the bot") + embed.set_author(icon_url=bot.user.avatar.with_format('png'), name="Bistro Help Manual | Page 2") + embed.set_image(url="https://media.discordapp.net/attachments/1325282246181130330/1328917037409374208/FF17CB1B-C653-4A06-A490-7BB9C4A38DFE.jpg?ex=678871ef&is=6787206f&hm=dba385547438a9343cd1c9c63b12a2b3e83af6c91ab06b9b0779d78e1d80142d&=&format=webp&width=2160&height=474") + embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the command.") + await interaction.response.edit_message(embed=embed) + + @discord.ui.button(label="3", style=discord.ButtonStyle.primary) + async def page_3(self, interaction: discord.Interaction, button: discord.ui.Button): + bot = interaction.client + post = db.market.find_one({"owner": interaction.user.id}) + pre = await get_pre(bot, interaction.message) + embed = discord.Embed(colour=0x8980d9, description="Buy, use, and view items in your inventory.") + embed.add_field(name=f"{pre}inventory", value="View your inventory") + embed.add_field(name=f"{pre}use ", value="Use or equip an item") + embed.add_field(name=f"{pre}buy", value="View shop and buy items") + embed.set_author(icon_url=bot.user.avatar.with_format('png'), name="Bistro Help Manual | Page 3") + embed.set_image(url="https://media.discordapp.net/attachments/1325282246181130330/1328917037409374208/FF17CB1B-C653-4A06-A490-7BB9C4A38DFE.jpg?ex=678871ef&is=6787206f&hm=dba385547438a9343cd1c9c63b12a2b3e83af6c91ab06b9b0779d78e1d80142d&=&format=webp&width=2160&height=474") + embed.set_footer(text="Arguments are inside [] and <>. [] is optional and <> is required. Do not include [] or <> in the command.") + await interaction.response.edit_message(embed=embed) + + @discord.ui.button(label="4", style=discord.ButtonStyle.primary) + async def page_4(self, interaction: discord.Interaction, button: discord.ui.Button): + bot = interaction.client + post = db.market.find_one({"owner": interaction.user.id}) + pre = await get_pre(bot, interaction.message) + embed = discord.Embed(colour=0x8980d9, description="Commands that have to do with the main bot.") + embed.add_field(name=f"{pre}ping", value="View the bot's ping") + embed.add_field(name=f"{pre}info", value="View information about BistroBot") + embed.add_field(name=f"{pre}invite", value="Get the invite URL") + embed.add_field(name=f"{pre}prefix ", value="Set server prefix. (requires `manage_server` permissions)") + embed.add_field(name=f"{pre}cooldown", value="Check what commands have cooldowns") + embed.set_author(icon_url=bot.user.avatar.with_format('png'), name="Bistro Help Manual | Page 4") + embed.set_image(url="https://media.discordapp.net/attachments/1325282246181130330/1328917037409374208/FF17CB1B-C653-4A06-A490-7BB9C4A38DFE.jpg?ex=678871ef&is=6787206f&hm=dba385547438a9343cd1c9c63b12a2b3e83af6c91ab06b9b0779d78e1d80142d&=&format=webp&width=2160&height=474") + await interaction.response.edit_message(embed=embed) async def setup(bot): - await bot.add_cog(Help(bot)) + await bot.add_cog(Help(bot)) \ No newline at end of file diff --git a/cogs/shop.py b/cogs/shop.py index 8afe01e..eb7a927 100644 --- a/cogs/shop.py +++ b/cogs/shop.py @@ -1,9 +1,11 @@ import discord from discord.ext import commands import datetime +from datetime import timedelta, datetime as dttm import requests import random import math +import traceback import time from discord.ext.commands import errors, converter from random import randint, choice as rnd @@ -21,112 +23,394 @@ from threading import Thread import extra import workers +import awards import schedule +import logging +from PIL import Image, ImageDraw +from io import BytesIO +from discord.ui import View, Button +import motor.motor_asyncio -client = MongoClient(config.mongo_client) +client = motor.motor_asyncio.AsyncIOMotorClient(config.mongo_client) db = client['siri'] +bbux = "<:BistroBux:1324936072760786964>" + class Shop(commands.Cog): def __init__(self, bot): self.bot = bot - self.prefix = 'r!' - self.countries = ['CHINA', 'FRANCE','GREECE', 'INDIA', 'ITALY', 'JAPAN', 'MEXICO', 'RUSSIA','TURKEY','UNITED KINGDOM', 'UNITED STATES'] + self.prefix = 'b.' + self.countries = ['CHINA', 'FRANCE','GREECE', 'INDIA', 'ITALY', 'JAPAN', 'MEXICO', 'RUSSIA','TURKEY','UNITED KINGDOM', 'UNITED STATES', 'CAFE', 'BAR', 'BAKERY', 'PIZZERIA', 'BRAZIL', 'SOUTH KOREA'] self.flags = {"china":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_China.png", "france":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_France.png", "greece":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Greece.png", "india":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_India.png", "italy": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Italy.png", "japan": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Japan.png", "mexico":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Mexico.png", "russia":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Russia.png", "turkey": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Turkey.png","united kingdom":"https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_United_Kingdom.png", - "united states": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_United_States.png"} - self.exp_needed = {"2": 250, "3": 500, "4": 1000, "5": 2000, "6": 4000} - self.unlocks = {"2": ['Experience Potion', '+10% Goodluck'], "3": ['Add 1 custom item to the menu'], "4": ['+10% Goodluck'], "5": ['Custom dine message', '+20% Goodluck'], "6": ["+30% Goodluck"]} - self.levelEmoji = {"1": "<:levelone:796813114652753992>", "2": "<:leveltwo:796813114779762729>", "3": "<:levelthree:796813114640433152>", "4": "<:levelfour:796813115055538186>", "5": "<:levelfive:796813115135229992>", "6": "<:levelsix:796813115194474506>"} - -# 2-3: 0.1, 4: 0.2, 5: 0.4, 6: 0.7 + "united states": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_United_States.png", "south korea": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_South_Korea.png", + "brazil": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Brazil.png", "bakery": "https://media.discordapp.net/attachments/1325282246181130330/1326089017204146176/3C40D072-4DD6-4E88-984E-6B840696A748.png?ex=67880b63&is=6786b9e3&hm=2ed7e672dc0967ec8b2d7684470bd7150460add228a638da00b8df678a1deb11&=&format=webp&quality=lossless&width=700&height=700", + "cafe": "https://media.discordapp.net/attachments/1325282246181130330/1326089126054854656/A65522AB-42C0-487E-B6D3-CB59D896DCF4.png?ex=67880b7d&is=6786b9fd&hm=85e39b1d2adb8566f4cbf118f93c70cee47f602f72e083e7c046c6763382b152&=&format=webp&quality=lossless&width=1046&height=1046", + "pizzeria": "https://media.discordapp.net/attachments/1325282246181130330/1326089393139748904/CC183333-A5B5-4C69-A1F1-3FACA9558B11.png?ex=67880bbc&is=6786ba3c&hm=a7c4367a54a4a44d73d87cb93463465d2a2eff9f4838a40a8f3e3677bf1c22b3&=&format=webp&quality=lossless&width=700&height=700", + "bar": "https://media.discordapp.net/attachments/1325282246181130330/1328889327542865992/3AEA0AEC-A6C7-4FEB-A70F-7A52E721ABBC.png?ex=679192a1&is=67904121&hm=486f7dfefbafb66b033840ba21d36a1a610a2a243685f606fc0c01a28f2939a9&=&format=webp&quality=lossless&width=700&height=700", + "singapore": "https://cdn2.iconfinder.com/data/icons/world-flag-icons/128/Flag_of_Singapore.png"} + self.exp_needed = {"2": 200, "3": 400, "4": 700, "5": 1000, "6": 1500, "7": 2000, "8": 2500, "9": 3000, "10": 3500, "11": 4000, "12": 5000, "13": 6000, "14": 7500, "15": 9000} + self.unlocks = {"2": ['Experience Potion', '+1 Luck Level'], "3": ['+1 Luck Level', '100 BB'], "4": ['Add a custom item to the menu', '100 BB'], "5": ['Custom dine message', '300 BB'], "6": ["Set a custom banner", '100 BB'], "7": ["500 BB"], "8": ["+1 Luck Level", '100 BB'], "9": ['1 of each Enhancement Fragment'],"10": ["Golden Apron", "500 BB"], "11": ['+50 Customers/day', '100 BB'], "12": ["Time Machine", '100 BB'], "13": ['+1 Luck Level', '100 BB'], "14": ["+1 Luck Level", '100 BB'], "15": ["Time Machine", "500 BB"]} + self.levelEmoji = {"1": "<:levelone:796813114652753992>", "2": "<:leveltwo:796813114779762729>", "3": "<:levelthree:796813114640433152>", "4": "<:levelfour:796813115055538186>", "5": "<:levelfive:1328924307581177861> ", "6": "<:levelsix:1328924417342046208>", + "7": "<:levelseven:1328924460417286244>", "8": "<:leveleight:1328924512783433788>", "9": "<:levelnine:1328924559013056512>", "10": "<:levelten:1328924635739459676>", "11": "<:leveleleven:1328924731285700670>", "12": "<:leveltwelve:1328924789871743028>", + "13": "<:levelthirteen:1328924832422690857>", "14": "<:levelfourteen:1328924878400651345>", "15": "<:levelfifteen:1328924948143673384>"} @commands.command(aliases=['Leaderboard', 'lb']) @commands.cooldown(1, 5, commands.BucketType.user) - async def leaderboard(self, ctx, page=1): - await ctx.trigger_typing() + async def leaderboard(self, ctx, page="1"): + if isinstance(page, int) or isinstance(page, str) and page.isdigit(): + page = int(page) + await ctx.typing() + start = (page - 1) * 8 + end = start + 8 + embed = discord.Embed(colour=0x8980d9, description="Global Bistro Leaderboard") + find_c = await db.market.find().sort("total_exp", -1).to_list(length=None) + for i, x in enumerate(find_c[start:end]): + exp = format(x['total_exp'], ",d") + level = x['level'] + emoji = "" + if i == 0: + emoji = " :first_place:" + elif i == 1: + emoji = " :second_place:" + elif i == 2: + emoji = " :third_place:" + embed.add_field(name=x['name'] + emoji, value=f"{self.levelEmoji[str(level)]} {exp} EXP", inline=False) + + embed.set_footer(text=f"Page {page} | b.lb {page + 1} for next page") + + prev_button = Button(label="←", custom_id="prev_page", style=discord.ButtonStyle.primary) + next_button = Button(label="→", custom_id="next_page", style=discord.ButtonStyle.primary) + + if page == 1: + prev_button.disabled = True + + prev_button.callback = lambda interaction: self.button_callback(interaction, ctx) + next_button.callback = lambda interaction: self.button_callback(interaction, ctx) + + view = View() + view.add_item(prev_button) + view.add_item(next_button) + + await ctx.send(embed=embed, view=view) + + elif isinstance(page, str): + # Handle the case where page is a restaurant name + r = await db.market.find_one({"name": page}) + if not r: + embed2 = discord.Embed(color=0x8980d9, description=f'<:RedTick:653464977788895252> Could not find a restaurant called "{page}". Try finding a page with `b.lb 7`') + embed2.set_footer(text="This query is CASE SENSITIVE!") + await ctx.send(embed=embed2) + return + tr_page = await db.market.find().sort("total_exp", -1).to_list(length=None) + res_rank = None + for idx, entry in enumerate(tr_page): + if entry['name'].lower() == page.lower(): + res_rank = idx + break + page_num = (res_rank // 8) + 1 + start = (page_num - 1) * 8 + end = start + 8 + embed = discord.Embed(colour=0x8980d9, description="Global Bistro Leaderboard") + for i, x in enumerate(tr_page[start:end]): + exp = format(x['total_exp'], ",d") + level = x['level'] + emoji = "" + if i == 0: + emoji = " :first_place:" + elif i == 1: + emoji = " :second_place:" + elif i == 2: + emoji = " :third_place:" + embed.add_field(name=x['name'] + emoji, value=f"{self.levelEmoji[str(level)]} {exp} EXP", inline=False) + + embed.set_footer(text=f"Page {page_num} | b.lb {page_num + 1} for next page") + + await ctx.send(embed=embed) + + async def button_callback(self, interaction, ctx): + footer_text = interaction.message.embeds[0].footer.text + current_page = int(footer_text.split("Page ")[1].split(" |")[0]) + + if interaction.user != ctx.author: + return + if interaction.data['custom_id'] == 'next_page': + await self.show_page(ctx, current_page + 1, interaction) + elif interaction.data['custom_id'] == 'prev_page' and not current_page == 1: + await self.show_page(ctx, current_page - 1, interaction) + + + async def show_page(self, ctx, page, interaction): + # Show the requested page again with the updated page number start = (page - 1) * 8 end = start + 8 - embed = discord.Embed(colour=0xa82021, description="Global Restaurant Leaderboard") - find_c = db.market.find().sort("exp", -1) - for x in find_c[start:end]: - exp = format(x['exp'], ",d") + embed = discord.Embed(colour=0x8980d9, description="Global Bistro Leaderboard") + find_c = await db.market.find().sort("total_exp", -1).to_list(length=None) + for i, x in enumerate(find_c[start:end]): + exp = format(x['total_exp'], ",d") level = x['level'] - embed.add_field(name=x['name'], value=f"{self.levelEmoji[str(level)]} {exp} EXP", inline=False) - embed.set_footer(text=f"Sort by: experience | r!lb {page+1} for next page") - await ctx.send(embed=embed) + emoji = "" + if i == 0: + emoji = " :first_place:" + elif i == 1: + emoji = " :second_place:" + elif i == 2: + emoji = " :third_place:" + embed.add_field(name=x['name'] + emoji, value=f"{self.levelEmoji[str(level)]} {exp} EXP", inline=False) + + embed.set_footer(text=f"Page {page} | b.lb {page + 1} for next page") + + prev_button = Button(label="←", custom_id="prev_page", style=discord.ButtonStyle.primary) + next_button = Button(label="→", custom_id="next_page", style=discord.ButtonStyle.primary) + + + + if page == 1: + prev_button.disabled = True + prev_button.callback = lambda interaction: self.button_callback(interaction, ctx) + next_button.callback = lambda interaction: self.button_callback(interaction, ctx) + + view = View() + view.add_item(prev_button) + view.add_item(next_button) + + await interaction.response.edit_message(embed=embed, view=view) @commands.command(aliases=['Delete']) @commands.cooldown(1, 3, commands.BucketType.user) async def delete(self, ctx): def ans(m): return m.author == ctx.message.author - post = db.market.find({"owner": ctx.author.id}) + post = await db.market.find({"owner": ctx.author.id}) if post: msg = await ctx.send("Are you sure you want to delete your restaurant? Deleting will erase all of your hardwork. If you're sure, reply with \"I'm sure\".") try: a = await self.bot.wait_for('message', check=ans, timeout=20) + resp = a.content.lower().replace("’", "'") except asyncio.TimeoutError: await ctx.send('You took too long to answer. Deletion canceled.') else: - if a.content.lower() == "i'm sure": - await ctx.send("Account deleted. Thanks for using Restaurant.") - db.market.delete_one({"owner": ctx.author.id}) + if resp == "i'm sure": + await ctx.send("Account deleted. Thanks for using Bistro.") + await db.market.delete_one({"owner": ctx.author.id}) else: await ctx.send('Deletion canceled.') else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`.") + + @commands.command(aliases=['Advertise', 'advert']) + @commands.cooldown(1, 3, commands.BucketType.user) + async def advertise(self, ctx): + post = await db.market.find_one({"owner": ctx.author.id}) + celebrities = ["Taylor Swift", "Lady Gaga", "Zac Efron", "6ix9ine", "Brendon Urie", "Tom Holland", "Katy Perry", "Ellen DeGeneres", "Logan Paul", "Benedict Cumberpatch", "John Cena", "Miley Cyrus", "Kylie Jenner", "Dua Lipa", "Ariana Grande", "Ryan Gosling", "Selena Gomez", "Shawn Mendes", "Keanu Reeves", "Beyoncé", "Rihanna", "Eminem", "Gordon Ramsey", "Billie Eilish", "Drake", "Kendrick Lamar", "Zendaya"] + def check(m): + return m.author == ctx.message.author + if post: + if post['advert']: + embed = discord.Embed(colour=0x8980d9) + if post['advert'] == 'social_media': + text = 'Social Media Ad' + emoji = ':mobile_phone:' + elif post['advert'] == 'tv_ad': + text = 'TV Advertisement' + emoji = ':tv:' + elif post['advert'] == 'web_ad': + text = 'Web Advertisement' + emoji = ':computer:' + elif post['advert'] == 'billboard': + text = 'Billboard' + emoji = ':frame_photo:' + embed.description = f'{ctx.author.mention}, Your {emoji} **{text}** is in progress! You cannot buy another advert until your current one ends at **1 AM ET**.' + await ctx.send(embed=embed) + else: + embed2 = discord.Embed(colour=0x8980d9, description = 'You can only buy one advert per day! Each advert lasts until the day is over.\n\n' + f'**[1] :mobile_phone: Social Media Ad** - {bbux}30\n'\ + '*An extra 30 customers today*\n'\ + f'**[2] :computer: Web Ad** - {bbux}50\n'\ + '*An extra 60 customers today*\n'\ + f'**[3] :tv: TV Ad** - {bbux}80\n'\ + '*An extra 100 customers today*\n'\ + f'**[4] :frame_photo: Billboard** - {bbux}100\n'\ + '*An extra 125 customers today*\n') + embed2.set_footer(text="You have 60 seconds to choose an option below.") + count = 0 + past_count = post['customers_per_day'] + msg = None + advert_start = False + async def e_button_callback(interaction, opt): + insufficient = "f" + await interaction.response.defer() + if opt == "1": + if post['money'] < 30: + insufficient = "t" + else: + count = 30 + advert_start = True + await self.take_money(user=ctx.author.id, count=30) + db.market.update_one({"owner": ctx.author.id}, {"$set": {"advert": "social_media"}}) + elif opt == "2": + if post['money'] < 50: + insufficent = "t" + else: + count = 60 + advert_start = True + await self.take_money(user=ctx.author.id, count=50) + db.market.update_one({"owner": ctx.author.id}, {"$set": {"advert": "web_ad"}}) + elif opt == "3": + if post['money'] < 80: + insufficient = "t" + else: + count = 100 + advert_start = True + await self.take_money(user=ctx.author.id, count=80) + db.market.update_one({"owner": ctx.author.id}, {"$set": {"advert": "tv_ad"}}) + elif opt == "4": + if post['money'] < 100: + insufficient = "t" + else: + count = 125 + advert_start = True + await self.take_money(user=ctx.author.id, count=100) + db.market.update_one({"owner": ctx.author.id}, {"$set": {"advert": "billboard"}}) + if insufficient == "t": + await ctx.send(f"<:RedTick:653464977788895252> You have an insufficent balance! You only have {bbux}{post['money']}.") + elif insufficient == "f": + await ctx.send(f"{ctx.author.mention}, You bought an advert and asked **{rnd(celebrities)}** to star in it. You will now get an extra **{count} customers** today.") + if msg: + await msg.delete() + if advert_start: + if "advertise" in post['tasks']: + user = post + ix = user['tasks'].index("advertise") + if user['task_list'][ix]['completed']+1 == 1: + await ctx.author.send(f"You have completed the **{user['task_list'][ix]['description']}** task. You have been awarded **{user['task_list'][ix]['rewards']} EXP**.") + await self.add_exp(user=ctx.author.id, count=user['task_list'][ix]['rewards'], multiplier=False) + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "advertise"},{"$set": {"task_list.$.completed": 1}}) + try: + await interaction.message.delete() + except: + pass + # imagine if i could code right........ + opt1 = Button(label="1", custom_id="a_opt1", style=discord.ButtonStyle.primary) + opt2 = Button(label="2", custom_id="a_opt2", style=discord.ButtonStyle.primary) + opt3 = Button(label="3", custom_id="a_opt3", style=discord.ButtonStyle.primary) + opt4 = Button(label="4", custom_id="a_opt4", style=discord.ButtonStyle.primary) + + opt1.callback = lambda interaction: e_button_callback(interaction, '1') + opt2.callback = lambda interaction: e_button_callback(interaction, '2') + opt3.callback = lambda interaction: e_button_callback(interaction, '3') + opt4.callback = lambda interaction: e_button_callback(interaction, '4') + + view = View() + view.add_item(opt1) + view.add_item(opt2) + view.add_item(opt3) + view.add_item(opt4) + + msg = await ctx.send(embed=embed2, view=view) + - @commands.command(aliases=['Worker']) + @commands.command(aliases=['Workers']) @commands.cooldown(1, 3, commands.BucketType.user) - async def worker(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) - if 'worker' in post: - if not post['worker']: - await ctx.send("<:RedTick:653464977788895252> You didn't hire a co-worker! Do `r!hire` to hire one!") + async def workers(self, ctx): + post = await db.market.find_one({"owner": ctx.author.id}) + if post['worker'] or post['chef']: + desc = [] + ratings = [] + for rating in post['ratings']: + ratings.append(rating['rating']) + avr = round(sum(ratings)/len(ratings)) + if avr <= 2: + wr = ["Working at {} is really hard...", "The food here at {} isn't the greatest...", "I hate working at {}! It's disgusting here!", "I want to work somewhere else...", "My boss doesn't care about his employees, I have never even gotten a raise... That's why I steal money from the register!", "This place gives me the creeps..", "I'd quit if I didn't have to pay child support...", "I'd rather work with Gordon Ramsay", "The food here is foul, not gonna lie", "This place needs a better owner!", "I dread waking up and coming here every day", "I am amazed that {} hasn't been shut down yet"] else: - ratings = [] - for rating in post['ratings']: - ratings.append(rating['rating']) - avr = round(sum(ratings)/len(ratings)) - if avr <= 2: - wr = ["Working at {} is really hard...", "The food here at {} isn't the greatest...", "I hate working at {}! It's disgusting here!", "I want to work somewhere else..."] - else: - wr = ["I love working at {}! The food is delicious here!", "{} is such a great place to work at, I absolutely love it!", "The working environment here at {} is so positive!", "I love working here!"] - comment = random.choice(wr).format(post['name']) + wr = ["I love working at {}! The food is delicious here!", "{} is such a great place to work at, I absolutely love it!", "The working environment here at {} is so positive!", "I love working here!", + "I actually like coming to work!", "Better than my old job at McDonalds...", "I love {}... even my boss is great!", "This place is the bomb!", "I love my boss so much!", "I am so glad to be a part of the team!", "I love {}!"] + comment = random.choice(wr).format(post['name']) + comment2 = random.choice(wr).format(post['name']) + if comment == comment2: + comment2 = random.choice(wr).format(post['name']) + if post['worker']: worker_name = post['worker_name'] - desc = f"**Co-Worker:** {worker_name}\n\n"\ + desc.append(f":technologist: **Manager:** {worker_name}\n\n"\ f"**EXP Bonus:** {round(post['worker'][worker_name][0]['exp']*100)}%\n"\ f"**Tips Bonus:** {round(post['worker'][worker_name][1]['tips']*100)}%\n"\ - f"**Earns You:** ${round(post['worker'][worker_name][2]['pay'])}/day\n"\ - f"\n**\"**{comment}**\"**" - embed = discord.Embed(colour=0xa82021, description=desc) - await ctx.send(embed=embed) + f"**Earns You:** <:BistroBux:1324936072760786964>{round(post['worker'][worker_name][2]['pay'])}/day\n"\ + f"\n**\"**{comment}**\"**") + if post['chef']: + country = post['country'] + chef = post['chef'] + if chef == "m": + chef_name = workers.chef_name[country][0]['m'] + cd = "20" + else: + chef_name = workers.chef_name[country][1]['w'] + cd = "40" + + desc.append(f":cook: **Chef:** {chef_name}\n\n"\ + f"**Cook Cooldown:** -{cd} seconds\n"\ + f"\n**\"**{comment2}**\"**") + + embed = discord.Embed(colour=0x8980d9, description="\n\n".join(desc)) + if post['colour']: + if post['colour'] == 0x171717: + embed.colour = random.randint(0, 0xFFFFFF) + else: + embed.colour = post['colour'] + await ctx.send(embed=embed) else: - await ctx.send("<:RedTick:653464977788895252> You didn't hire a co-worker! Do `r!hire` to get one!") + await ctx.send("<:RedTick:653464977788895252> You didn't hire a co-worker! Do `b.hire` to get one!") @commands.command(aliases=['Hire']) @commands.cooldown(1, 3, commands.BucketType.user) async def hire(self, ctx): def a(m): return m.author == ctx.message.author - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) c = str(post['country']) available = workers.list[c] + chefs_avail = workers.chef_name[c] wrks = [[key for key in available[0]][0], [key for key in available[1]][0], [key for key in available[2]][0], [key for key in available[3]][0]] - wd = f"`{[key for key in available[0]][0]}` **-5% EXP** | **+40% Tips** | **Earns $5/day**\n"\ - f"`{[key for key in available[1]][0]}` **+12% EXP** | **+24% Tips** | **Earns $6/day**\n"\ - f"`{[key for key in available[2]][0]}` **+5% EXP** | **-20% Tips** | **Earns $12/day**\n"\ - f"`{[key for key in available[3]][0]}` **+30% EXP** | **+20% Tips** | **Earns $2/day**" - embed = discord.Embed(description=f"Which worker would you like to hire? You can only have one at a time.\n\nEach employee costs $500 upfront and an additional $50 taken away from the daily command.\n\n{wd}") + wd = f"<:W1:1325370058372812860> `{[key for key in available[0]][0]}` **-5% EXP** | **+40% Tips** | **Earns you <:BistroBux:1324936072760786964>14/day**\n"\ + f"<:M1:1325372100529225738> `{[key for key in available[1]][0]}` **+10% EXP** | **+20% Tips** | **Earns you <:BistroBux:1324936072760786964>12/day**\n"\ + f"<:W2:1325370773212233849> `{[key for key in available[2]][0]}` **+5% EXP** | **-10% Tips** | **Earns you <:BistroBux:1324936072760786964>20/day**\n"\ + f"<:M2:1325373899688509500> `{[key for key in available[3]][0]}` **+25% EXP** | **+10% Tips** | **Earns you <:BistroBux:1324936072760786964>8/day**" + chefs = [chefs_avail[0]['m'], chefs_avail[1]['w']] + chef_names = f"<:ChefM:1329677738059104307> `{chefs_avail[0]['m']}` **-20s Cook Cooldown** | **Costs $200 upfront, $20 from daily**\n"\ + f"<:ChefW:1329678594741637171> `{chefs_avail[1]['w']}` **-40s Cook Cooldown** | **Costs $350 upfront, $40 from daily**" + embed = discord.Embed(description=f"Which worker would you like to hire? You can only have one manager and one chef at a time.\n\n**Manager**:\nEach manager costs <:BistroBux:1324936072760786964>500 upfront and an additional <:BistroBux:1324936072760786964>50 taken away from the daily command.\n{wd}"\ + f"\n\n**Chef**:\nYou must have at least 500 customers to hire a chef\n{chef_names}\n\n**__NOTE__**: You must re-pay the upfront fee when switching workers") embed.set_footer(text="You have 60 seconds to reply.") await ctx.send(embed=embed) msg = await self.bot.wait_for('message', check=a, timeout=20) chosen = msg.content.capitalize() - if not msg.content in wrks: - await ctx.send(f"<:RedTick:653464977788895252> Error! That's not in the list of workers! Example: `{[key for key in available[1]][0]}`") - else: + if msg.content in chefs: + if post['customers'] < 500: + await ctx.send("<:RedTick:653464977788895252> You must have had at least 500 customers to hire a chef!") + return + if msg.content == chefs[0]: + if not post['money'] >= 200: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money.") + return + else: + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"chef": "m"}}) + emb = discord.Embed(colour=0x8980d9, description=f"Hello, {ctx.author.name.capitalize()}!\n\nThanks for hiring me! I hope that I can help make your restaurant amazing! If you ever want to check on me, do `b.workers`.") + emb.set_author(name=f"Message from {chefs_avail[0]['m']}", icon_url="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcStHcjAvE9Z_eC1quY6moMTU4aLWNkiusCAdA&s") + await ctx.send(embed=emb) + await self.take_money(user=ctx.author.id, count=200) + else: + if not post['money'] >= 350: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money.") + return + else: + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"chef": "w"}}) + emb = discord.Embed(colour=0x8980d9, description=f"Hello, {ctx.author.name.capitalize()}!\n\nThanks for hiring me! I hope that I can help make your restaurant amazing! If you ever want to check on me, do `b.workers`.") + emb.set_author(name=f"Message from {chefs_avail[1]['w']}", icon_url="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcStHcjAvE9Z_eC1quY6moMTU4aLWNkiusCAdA&s") + await ctx.send(embed=emb) + await self.take_money(user=ctx.author.id, count=350) + + elif msg.content in wrks: chw = None for x in available: if chosen in x: @@ -135,49 +419,57 @@ def a(m): await ctx.send("<:RedTick:653464977788895252> You don't have enough money.") else: if not 'worker' in post: - db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker": None}}) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker_name": None}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker": None}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker_name": None}}) else: pass + if post['worker'] == chosen: + await ctx.send(f"<:RedTick:653464977788895252> You already have this worker!") + return await self.take_money(user=ctx.author.id, count=500) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker": chw}}) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker_name": chosen}}) - me = discord.Embed(colour=0xa82021, description=f"Hello, {ctx.author.name.capitalize()}!\n\nThanks for hiring me! I hope that I can help make your restaurant the best in the world! If you ever want to check on me, do `r!worker`.") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker": chw}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"worker_name": chosen}}) + award = await self.get_award(ctx.author.id, "worker") + me = discord.Embed(colour=0x8980d9, description=f"Hello, {ctx.author.name.capitalize()}!\n\nThanks for hiring me! I hope that I can help make your restaurant the best in the world! If you ever want to check on me, do `b.workers`.") me.set_author(name=f"Message from {chosen}", icon_url="http://paixlukee.dev/m/SKRFY.png") await ctx.send(embed=me) + if award: + await ctx.send(f"{ctx.author.mention}, You achieved the {awards.awards["worker"]["emoji"]} **Teamwork** award for hiring a worker!") + else: + await ctx.send(f"<:RedTick:653464977788895252> That's not in the list of workers! Example: `{[key for key in available[1]][0]}`") @commands.command(aliases=['restaurantfuse']) async def fuse(self, ctx): - embed = discord.Embed(colour=0xa82021) - embed.set_author(name="Restaurant Fusing", icon_url=ctx.me.avatar_url_as(format='png')) + embed = discord.Embed(colour=0x8980d9) + embed.set_author(name="Restaurant Fusing", icon_url=ctx.bot.user.avatar.url) embed.set_image(url="https://i.ibb.co/yNMrNnq/restaurantfuse.png") embed.description = "Want to have two food types in one restaurant?\n"\ "Fusing your restaurant will mix foods from two different countries.\n\n"\ - "To fuse your restaurant, you need to have **2,000 or more experience**. It costs **$1,000** to fuse.\n\n"\ - "Do `r!rfuse` to fuse your restaurant." + "To fuse your restaurant, you need to have **2,000 or more experience**. It costs **<:BistroBux:1324936072760786964>1,000** to fuse.\n\n"\ + "Do `b.rfuse` to fuse your restaurant." await ctx.send(embed=embed) @commands.command() async def rfuse(self, ctx): def nc(m): return m.author == ctx.message.author - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) if not post: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `r!restaurant`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.restaurant`.") elif post['exp'] <= 2000: await ctx.send("<:RedTick:653464977788895252> You don't have enough experience to fuse!") elif post['money'] <= 1000: await ctx.send("<:RedTick:653464977788895252> You don't have enough money to fuse!") else: - embed = discord.Embed(colour=0xa82021, description="What country would you like to fuse with?") + embed = discord.Embed(colour=0x8980d9, description="What country would you like to fuse with?") embed.set_footer(text="You have 90 seconds to answer.") - embed.set_author(name="Restaurant Fusing", icon_url=ctx.me.avatar_url_as(format='png')) + embed.set_author(name="Restaurant Fusing", icon_url=ctx.bot.user.avatar.url) choice = await self.bot.wait_for('message', check=nc, timeout=90) if not choice.content.upper() in self.countries: - embed = discord.Embed(colour=0xa82021, title="Fusing failed.", description="That is not a vaild country.") + embed = discord.Embed(colour=0x8980d9, title="Fusing failed.", description="That is not a vaild country.") else: pass @@ -185,77 +477,88 @@ def nc(m): @commands.command(aliases=['Menu']) @commands.cooldown(1, 3, commands.BucketType.user) async def menu(self, ctx, *, restaurant=None): + await ctx.typing() def nc(m): return m.author == ctx.message.author if ctx.message.mentions: if len(ctx.message.mentions) >= 2: - restaurant = db.market.find_one({"owner":ctx.message.mentions[1].id})['name'] + restaurant = await db.market.find_one({"owner":ctx.message.mentions[1].id})['name'] else: - restaurant = db.market.find_one({"owner":ctx.message.mentions[0].id})['name'] + restaurant = await db.market.find_one({"owner":ctx.message.mentions[0].id})['name'] if not restaurant: - await ctx.send("<:RedTick:653464977788895252> You must include the restaurant name. Example: `r!menu McDonalds`") - else: - post = db.market.find({"name": restaurant}) - if post.count() > 1: - embed = discord.Embed(colour=0xa82021, title="Multiple results found.") - cn = 0 - desc = "" - n = [] - for x in post: - cn += 1 - n.append({str(cn):x}) - own = self.bot.get_user(x['owner']) - desc += f"[{cn}] {x['name']} | {own}\n" - embed.description = desc - embed.set_footer(text="You have 90 seconds to reply with the number.") + try: + pr = await db.market.find_one({"owner": ctx.author.id}) + restaurant = pr['name'] + except: + await ctx.send("<:RedTick:653464977788895252> You must include the restaurant name. Example: `b.menu McDonalds`") + return + post = await db.market.find({"name": restaurant}).to_list(length=None) + post_count = await db.market.count_documents({"name": restaurant}) + if post_count > 1: + embed = discord.Embed(colour=0x8980d9, title="Multiple results found.") + cn = 0 + desc = "" + n = [] + for x in post: + cn += 1 + n.append({str(cn):x}) + own = self.bot.get_user(x['owner']) + desc += f"[{cn}] {x['name']} | {own}\n" + embed.description = desc + embed.set_footer(text="You have 90 seconds to reply with the number.") + await ctx.send(embed=embed) + choice = await self.bot.wait_for('message', check=nc, timeout=90) + if not choice.content.isdigit() or len(choice.content) > cn or len(choice.content) < 1: + embed = discord.Embed(colour=0x8980d9, title="Failed", description="Invalid number.") await ctx.send(embed=embed) - choice = await self.bot.wait_for('message', check=nc, timeout=90) - if not choice.content.isdigit() or len(choice.content) > cn or len(choice.content) < 1: - embed = discord.Embed(colour=0xa82021, title="Failed", description="Invalid number.") - await ctx.send(embed=embed) - else: - pn = int(choice.content) - embed = discord.Embed() - country = n[pn-1][str(pn)]['country'] - embed.set_author(icon_url=self.flags[country], name=f"{n[pn-1][str(pn)]['name']}'s Menu") - desc = "" - for x in n[pn-1][str(pn)]['items']: - desc += f"{x['name']} | ${x['price']} | {x['sold']} Sold\n" - embed.description = desc - await ctx.send(embed=embed) - elif post.count() == 1: - post = db.market.find_one({"name": restaurant}) + else: + pn = int(choice.content) embed = discord.Embed() - country = str(post['country']) - embed.set_author(icon_url=self.flags[country], name=f"{post['name']}'s Menu") + country = n[pn-1][str(pn)]['country'] + embed.set_author(icon_url=self.flags[country], name=f"{n[pn-1][str(pn)]['name']}'s Menu") desc = "" - for x in post['items']: - desc += f"{x['name']} | ${x['price']} | {x['sold']} Sold\n"#| {x['stock']} in Stock + for x in n[pn-1][str(pn)]['items']: + desc += f"{x['name']} | <:BistroBux:1324936072760786964>{x['price']} | {x['sold']} Sold\n" embed.description = desc await ctx.send(embed=embed) - else: - await ctx.send("<:RedTick:653464977788895252> I couldn't find that restaurant in our database. Did you spell it right? Names are case sensitive.") + elif post_count == 1: + post = await db.market.find_one({"name": restaurant}) + embed = discord.Embed() + country = str(post['country']) + embed.set_author(icon_url=self.flags[country], name=f"{post['name']}'s Menu") + desc = "" + for x in post['items']: + desc += f"{x['name']} | <:BistroBux:1324936072760786964>{x['price']} | {x['sold']} Sold\n"#| {x['stock']} in Stock + embed.description = desc + if post['colour']: + if post['colour'] == 0x171717: + embed.colour = random.randint(0, 0xFFFFFF) + else: + embed.colour = post['colour'] + await ctx.send(embed=embed) + else: + await ctx.send("<:RedTick:653464977788895252> I couldn't find that restaurant in our database. Did you spell it right? Names are case sensitive.") @commands.command(aliases=['Rate']) @commands.cooldown(1, 10, commands.BucketType.user) async def rate(self, ctx, user:discord.User=None): - post = db.market.find_one({"owner": user.id}) + post = await db.market.find_one({"owner": user.id}) def nc(m): return m.author == ctx.message.author if not user: - await ctx.send("<:RedTick:653464977788895252> You must tag the restaurant owner. Example: `r!rate @lukee#0420`") + await ctx.send("<:RedTick:653464977788895252> You must tag the restaurant owner. Example: `b.rate @paixlukee`") elif user == ctx.author: await ctx.send("<:RedTick:653464977788895252> You cannot rate your own restaurant.") else: - posts = db.market.find_one({"owner": user.id}) + posts = await db.market.find_one({"owner": user.id}) rus = [] for x in posts['ratings']: rus.append(x['user']) if str(ctx.author.id) in rus: await ctx.send("<:RedTick:653464977788895252> You already rated this restaurant.") else: - embed = discord.Embed(colour=0xa82021, description=f"Out of 5 stars, how would you rate {post['name']}?") + embed = discord.Embed(colour=0x8980d9, description=f"Out of 5 stars, how would you rate {post['name']}?") embed.set_footer(text="You have 90 seconds to reply") msg = await ctx.send(embed=embed) rating = await self.bot.wait_for('message', check=nc, timeout=90) @@ -264,302 +567,537 @@ def nc(m): except: pass if not rating.content.isdigit() or int(rating.content) > 5 or int(rating.content) < 0: - embed = discord.Embed(colour=0xa82021, description="The rating must be from 0-5.") + embed = discord.Embed(colour=0x8980d9, description="The rating must be from 0-5.") embed.set_author(name="Failed.") await msg.edit(embed=embed) else: - embed = discord.Embed(colour=0xa82021, description=f"You have successfully rated {post['name']}.") + embed = discord.Embed(colour=0x8980d9, description=f"You have successfully rated {post['name']}.") await msg.edit(embed=embed) - db.market.update_one({"owner": user.id}, {"$push":{"ratings": {"rating": int(rating.content), "user":str(ctx.author.id)}}}) + await db.market.update_one({"owner": user.id}, {"$push":{"ratings": {"rating": int(rating.content), "user":str(ctx.author.id)}}}) @commands.group(aliases=['Buy']) - @commands.cooldown(1, 5, commands.BucketType.user) async def buy(self, ctx): if ctx.invoked_subcommand is None: - embed = discord.Embed(colour=0xa82021, title="'Buy' Command Group", description="`r!buy custom` - **Buy a restaurant customisation chest**\n`r!buy food` - **Buy a menu item and have it added to your menu**\n`r!buy item` - **Buy an item from the store**") - await ctx.send(embed=embed) - - @buy.command(aliases=['Boost']) - async def boost(self, ctx): - x = 'x' - #def nc(m): - #return m.author == ctx.message.author - #post = db.market.find_one({"owner": ctx.author.id}) - if x == 'y': - embed = discord.Embed(colour=0xa82021, title="Which chest would you like to buy?", description="[1] Double EXP - 24 Hours - $900 <:EarningsBoost:651474110022418433>\n[2] Profile Banner Chest - $1,000 <:EarningsBoost2:651474232219271210>") - embed.set_footer(text="You have 90 seconds to reply with the number") + embed = discord.Embed(colour=0x8980d9, title="'Buy' Command Group", description="`b.buy custom` - **Buy a restaurant customisation chest**\n`b.buy chest` - **Buy a chest filled with random goods**\n`b.buy food` - **Buy a menu item and have it added to your menu**\n`b.buy item` - **Buy an item from the store**") await ctx.send(embed=embed) - choice = await self.bot.wait_for('message', check=nc, timeout=90) - if int(choice.content) == 1: - if post['money'] < 200: - await ctx.send("You don't have enough money for this.") - else: - rn = random.randint(1,3) - if not rn == 1: - chosen = rnd(items.colours['common']) - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['colour']} (Common)") - embed.set_thumbnail(url="http://pixelartmaker.com/art/5dd01d7e459201b.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['colour']} to use it.") - await ctx.send(embed=embed, content='you opened a Profile Colour Chest and received...') + + @buy.command(aliases=['Chest', 'chests']) + async def chest(self, ctx): + await ctx.typing() + post = await db.market.find_one({"owner": ctx.author.id}) + if not post: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Start one with `b.") + return + msg = None + embed = discord.Embed(colour=0x8980d9, title="Which chests would you like to buy?", description= + "Chests can include: banners, colors, shop items, money or enhancement fragments\n\n"\ + f"**[1] <:CommonChest:1332452120787423302> Common Chest** - {bbux}200\n"\ + f"**[2] <:UncommonChest:1332452893323694141> Uncommon Chest** - {bbux} 300") + embed.set_footer(text="Choose a number below to buy it.") + async def chest_cb1(interaction, msg): + if post['money'] < 200: + await interaction.followup.send(f"<:RedTick:653464977788895252> You don't have enough money! Balance: {bbux}{post['money']}") + return + await self.take_money(ctx.author.id, 200) + options = ['color'] * 10 + ['banner'] * 7 + ['rod'] * 4 + ['apron'] * 4 + ['extinguisher'] * 2 + ['exp'] * 3 + ['tm'] * 3 + ['money'] * 3 + ['fragment'] * 2 + ran_opt1 = rnd(options) + ran_opt2 = rnd(options) + both_opts = [ran_opt1, ran_opt2] + opts_toprint = [] + for opt in both_opts: + if opt == 'color': + owned_colors = {item['colour']['colour'] for item in post['inventory'] if 'colour' in item} + colors_f = { + rarity: [color for color in items.colours[rarity] if color['colour'] not in owned_colors] + for rarity in items.colours + } + rarity = 'common' + if not colors_f['common']: + rarity = 'uncommon' + chosen = rnd(colors_f[rarity]) + chosen['rarity'] = rarity.capitalize() + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) + opts_toprint.append(f"<:ColourIcon:659418340703469584> {chosen['colour']}") + elif opt == 'banner': + owned_banners = {item['banner']['name'] for item in post['inventory'] if 'banner' in item} + banners_f = { + rarity: [banner for banner in items.banners[rarity] if banner['name'] not in owned_banners] + for rarity in ['common', 'uncommon', 'rare'] + } + rr = ['common'] * 6 + ['uncommon'] * 3 + ['rare'] + rarity = rnd(rr) + chosen = rnd(banners_f[rarity]) + chosen['rarity'] = rarity.capitalize() + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) + opts_toprint.append(f"<:BannerIcon:657457820295495699> {chosen['name']}") + elif opt == 'rod': + opts_toprint.append("<:FishingRod:1333893065542336523> Fishing Rod") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "fish"}}}) + elif opt == 'tm': + opts_toprint.append("<:TimeMachine:1333889857688436847> Time Machine") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "tm"}}}) + elif opt == 'exp': + opts_toprint.append("<:ExperiencePotion:715822985780658238> Experience Potion") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "ep"}}}) + elif opt == 'extinguisher': + opts_toprint.append("<:FireExtinguisher:1333891774472523888> Fire Extinguisher") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "fe"}}}) + elif opt == 'apron': + if 'apron_uses' in post: + uses = post['apron_uses'] + opts_toprint.append("<:GoldenApron:1327865002559803452> +20 Golden Apron uses") + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"apron_uses": 20}}) else: - chosen = rnd(items.colours['uncommon']) - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['colour']} (Uncommon)") - embed.set_thumbnail(url="http://pixelartmaker.com/art/5dd01d7e459201b.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['colour']} to use it.") - await ctx.send(embed=embed, content='you opened a Profile Colour Chest and received...') - elif int(choice.content) == 2: - if post['money'] < 200: - await ctx.send("You don't have enough money for this.") - else: - rn = random.randint(1,3) - if not rn == 1: - chosen = rnd(items.banners['common']) - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['name']} (Common) [View banner]({chosen['url']})") - embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['name']} to use it.") - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') + opts_toprint.append("<:GoldenApron:1327865002559803452> Golden Apron") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"apron_uses": 20}}) + elif opt == 'money': + rn_m = random.randint(60, 130) + opts_toprint.append(f"{bbux}{rn_m}") + await self.add_money(ctx.author.id, rn_m) + elif opt == 'fragment': + frag = await self.add_rand_fragment(ctx.author.id) + if not frag: + await self.add_money(ctx.author.id, 150) + opts_toprint.append(f"{bbux}150") else: - chosen = rnd(items.banners['uncommon']) - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['name']} (Uncommon) [View banner]({chosen['url']})") - embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['name']} to use it.") - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') - else: - await ctx.send("That is not an option.") + if frag == 'agility': + opts_toprint.append(f"<:AgilityFragment:1331502143760236574> Fragment of Agility") + elif frag == 'opportunity': + opts_toprint.append(f"<:OpportunityFragment:1331505178959937556> Fragment of Opportunity") + elif frag == 'endearing': + opts_toprint.append(f"<:EndearingFragment:1331823626080620574> Fragment of Endearing") + elif frag == 'ambience': + opts_toprint.append(f"<:AmbienceFragment:1331825947036483675> Fragment of Ambience") + embed_2 = discord.Embed(colour=0x8980d9, description="* "+"\n* ".join(opts_toprint)) + embed_2.set_thumbnail(url="https://media.discordapp.net/attachments/1325282246181130330/1332452463932080138/New_Piskel_49.png?ex=67954e8f&is=6793fd0f&hm=8e702bf420f47d161ead96e3f305fac5ac9d457ce306ec55c690bbee683a8f44&=&format=webp&quality=lossless&width=1092&height=780") + await ctx.send(embed=embed_2, content=f"{ctx.author.mention}, you opened a Common Chest and received...") + await msg.delete() + try: + await interaction.message.delete() + except: + pass + + + async def chest_cb2(interaction, msg): + if post['money'] < 300: + await interaction.followup.send(f"<:RedTick:653464977788895252> You don't have enough money! Balance: {bbux}{post['money']}") + return + options = ['color'] * 8 + ['banner'] * 10 + ['apron'] * 7 + ['extinguisher'] * 2 + ['exp'] * 5 + ['tm'] * 4 + ['money'] * 3 + ['fragment'] * 3 + ran_opt1 = rnd(options) + ran_opt2 = rnd(options) + both_opts = [ran_opt1, ran_opt2] + opts_toprint = [] + for opt in both_opts: + if opt == 'color': + owned_colors = {item['colour']['colour'] for item in post['inventory'] if 'colour' in item} + colors_f = { + rarity: [color for color in items.colours[rarity] if color['colour'] not in owned_colors] + for rarity in items.colours + } + rarity = 'uncommon' + chosen = rnd(colors_f[rarity]) + chosen['rarity'] = rarity.capitalize() + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) + opts_toprint.append(f"<:ColourIcon:659418340703469584> {chosen['colour']}") + elif opt == 'banner': + owned_banners = {item['banner']['name'] for item in post['inventory'] if 'banner' in item} + banners_f = { + rarity: [banner for banner in items.banners[rarity] if banner['name'] not in owned_banners] + for rarity in ['common', 'uncommon', 'rare'] + } + rr = ['uncommon'] * 4 + ['rare'] * 2 + rarity = rnd(rr) + if not banners_f['rare']: + rarity = 'uncommon' + chosen = rnd(banners_f[rarity]) + chosen['rarity'] = rarity.capitalize() + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) + opts_toprint.append(f"<:BannerIcon:657457820295495699> {chosen['name']}") + elif opt == 'tm': + opts_toprint.append(":clock: Time Machine") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "tm"}}}) + elif opt == 'exp': + opts_toprint.append("<:ExperiencePotion:715822985780658238> Experience Potion") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "ep"}}}) + elif opt == 'extinguisher': + opts_toprint.append(":fire_extinguisher: Fire Extinguisher") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "fe"}}}) + elif opt == 'money': + rn_m = random.randint(100, 200) + opts_toprint.append(f"{bbux}{rn_m}") + await self.add_money(ctx.author.id, rn_m) + elif opt == 'apron': + if 'apron_uses' in post: + uses = post['apron_uses'] + opts_toprint.append("<:GoldenApron:1327865002559803452> +20 Golden Apron uses") + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"apron_uses": 20}}) + else: + opts_toprint.append("<:GoldenApron:1327865002559803452> Golden Apron") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"apron_uses": 20}}) + elif opt == 'fragment': + frag = await self.add_rand_fragment(ctx.author.id) + if frag == 'agility': + opts_toprint.append(f"<:AgilityFragment:1331502143760236574> Fragment of Agility") + elif frag == 'opportunity': + opts_toprint.append(f"<:OpportunityFragment:1331505178959937556> Fragment of Opportunity") + elif frag == 'endearing': + opts_toprint.append(f"<:EndearingFragment:1331823626080620574> Fragment of Endearing") + elif frag == 'ambience': + opts_toprint.append(f"<:AmbienceFragment:1331825947036483675> Fragment of Ambience") + embed_2 = discord.Embed(colour=0x8980d9, description="* "+"\n* ".join(opts_toprint)) + embed_2.set_thumbnail(url="https://media.discordapp.net/attachments/1325282246181130330/1332453341170765844/New_Piskel_50.png?ex=67954f60&is=6793fde0&hm=557c19c74ce95c28e58377a0bb62f4714c73eb9147edd14c2fd55c3106523ad5&=&format=webp&quality=lossless&width=1092&height=780") + await ctx.send(embed=embed_2, content=f"{ctx.author.mention}, you opened an Uncommon Chest and received...") + await msg.delete() + try: + await interaction.message.delete() + except: + pass + + ch_btn1 = Button(label="1", custom_id="chest_btn1", style=discord.ButtonStyle.primary) + ch_btn2 = Button(label="2", custom_id="chest_btn2", style=discord.ButtonStyle.primary) - else: - await ctx.send("Boosts are still in the works! Suggest what you want to see here: ") + ch_btn1.callback = lambda interaction: chest_cb1(interaction, msg) + ch_btn2.callback = lambda interaction: chest_cb2(interaction, msg) + + view = View() + view.add_item(ch_btn1) + view.add_item(ch_btn2) + msg = await ctx.send(embed=embed, view=view) + @buy.command(aliases=['Item']) async def item(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) def nc(m): return m.author == ctx.message.author if post['level'] >= 2: - uy = "$80 <:ExperiencePotion:715822985780658238>" - else: - uy = ":lock: Unlocks at Level 2" - embed = discord.Embed(colour=0xa82021, title="Which item would you like to buy?", description=f"[1] Fishing Rod - $60 :fishing_pole_and_fish:\n[2] Experience Potion (+50 EXP) - {uy}") - embed.set_footer(text="You have 90 seconds to reply with the number, or say 'cancel' to cancel.") - await ctx.send(embed=embed) - choice = await self.bot.wait_for('message', check=nc, timeout=90) - if choice.content == '1': - if post['money'] < 60: - await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") - else: - await ctx.send(f"{ctx.author.mention}, You bought 1 Fishing Rod. Do `r!fish` to use it.") - await self.take_money(user=ctx.author.id, count=60) - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "fish"}}}) - elif choice.content == '2': - if post['money'] < 80: - await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this!") - elif not post['level'] >= 2: - await ctx.send("<:RedTick:653464977788895252> You must be at least Level 2 to unlock this! For more information, send `r!level`.") - else: - await ctx.send(f"{ctx.author.mention}, You bought 1 Experience Potion. Do `r!use Experience Potion` to use it.") - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "ep"}}}) - await self.take_money(user=ctx.author.id, count=80) - elif choice.content.lower() == 'cancel': - await ctx.send("Cancelled.") + uy = "<:BistroBux:1324936072760786964>100 " else: - pass + uy = ":lock: *Unlocks at Level 2*" + embed = discord.Embed(colour=0x8980d9, title="Which item would you like to buy?", description= + "**[1] <:FishingRod:1333893065542336523> Fishing Rod -** <:BistroBux:1324936072760786964>60\n"\ + "Allows you to fish with the `b.fish` command (Chance of breaking with each use)\n"\ + "**[2] <:FishingBoat:1333885562519814265> Fishing Boat -** <:BistroBux:1324936072760786964>150\n"\ + "You earn +25% EXP and +30% BB while fishing\n"\ + f"**[3] <:ExperiencePotion:715822985780658238> Experience Potion -** {uy}\n"\ + "Gives you +50 EXP\n"\ + f"**[4] <:TimeMachine:1333889857688436847> Time Machine -** {bbux}60\n"\ + "Allows you to reset all cooldowns (excl. daily & weekly)\n"\ + f"**[5] <:GoldenApron:1327865002559803452> Golden Apron -** {bbux}180\n"\ + "Gives you +25% earnings on the work and trivia commands (20 uses)\n" + f"**[6] <:FireExtinguisher:1333891774472523888> Fire Extinguisher -** {bbux}45\n"\ + "Clears a kitchen fire" + ) + embed.set_footer(text="You have 90 seconds to click a number below.") + msg = None + async def it_button_callback(interaction, option): + await interaction.response.defer() + if option == '1': + if post['money'] < 60: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") + else: + await ctx.send(f"{ctx.author.mention}, You bought a Fishing Rod! Do `b.fish` to use it.") + await self.take_money(user=ctx.author.id, count=60) + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "fish"}}}) + if option == '2': + if post['money'] < 150: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") + else: + if 'fishing_boat' in post['bonuses']: + await ctx.send("<:RedTick:653464977788895252> You already own a fishing boat!") + await ctx.send(f"{ctx.author.mention}, You bought a Fishing Boat! You will now earn +25% EXP and +30% {bbux} with the `b.fish` command.") + await self.take_money(user=ctx.author.id, count=150) + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"bonuses": "fishing_boat"}}) + elif option == '3': + if post['money'] < 100: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this!") + elif not post['level'] >= 2: + await ctx.send("<:RedTick:653464977788895252> You must be at least Level 2 to unlock this! For more information, send `b.level`.") + else: + await ctx.send(f"{ctx.author.mention}, You bought an Experience Potion! Do `b.use Experience Potion` to use it.") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "ep"}}}) + await self.take_money(user=ctx.author.id, count=80) + elif option == '4': + if post['money'] < 60: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this!") + else: + await self.take_money(user=ctx.author.id, count=85) + await ctx.send(f"{ctx.author.mention}, You bought a Time Machine! Do `b.use Time Machine` to use it.") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "tm"}}}) + + elif option == '5': + if post['money'] < 180: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this!") + else: + if 'apron_uses' in post: + await self.take_money(user=ctx.author.id, count=180) + uses = post['apron_uses'] + await ctx.send(f"{ctx.author.mention}, You have upgraded your Golden Apron! You now have {uses+20} uses.") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"apron_uses": uses+20}}) + else: + await self.take_money(user=ctx.author.id, count=180) + await ctx.send(f"{ctx.author.mention}, You bought a Golden Apron! You can use this 20 times (`b.work` & `b.trivia` only).") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"apron_uses": 20}}) + elif option == '6': + if post['money'] < 45: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this!") + else: + await self.take_money(user=ctx.author.id, count=45) + await ctx.send(f"{ctx.author.mention}, you bought a Fire Extinguisher! Use this with `b.use Fire Extinguisher`") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "fe"}}}) + if msg: + await msg.delete() + try: + await interaction.message.delete() + except: + pass + + #kms + opt1 = Button(label="1", custom_id="opt1", style=discord.ButtonStyle.primary) + opt2 = Button(label="2", custom_id="opt2", style=discord.ButtonStyle.primary) + opt3 = Button(label="3", custom_id="opt3", style=discord.ButtonStyle.primary) + opt4 = Button(label="4", custom_id="opt4", style=discord.ButtonStyle.primary) + opt5 = Button(label="5", custom_id="opt5", style=discord.ButtonStyle.primary) + opt6 = Button(label="6", custom_id="opt6", style=discord.ButtonStyle.primary) + + if 'fishing_boat' in post['bonuses']: + opt2.disabled = True + opt1.callback = lambda interaction: it_button_callback(interaction, '1') + opt2.callback = lambda interaction: it_button_callback(interaction, '2') + opt3.callback = lambda interaction: it_button_callback(interaction, '3') + opt4.callback = lambda interaction: it_button_callback(interaction, '4') + opt5.callback = lambda interaction: it_button_callback(interaction, '5') + opt6.callback = lambda interaction: it_button_callback(interaction, '6') + + view = View() + view.add_item(opt1) + view.add_item(opt2) + view.add_item(opt3) + view.add_item(opt4) + view.add_item(opt5) + view.add_item(opt6) + + msg = await ctx.send(embed=embed, view=view) + @buy.command(aliases=['Custom']) async def custom(self, ctx): def nc(m): return m.author == ctx.message.author - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) if not 'colour' in post: - db.market.update_one({"owner": ctx.author.id}, {"$set":{"colour": None}}) - db.market.update_one({"owner": ctx.author.id}, {"$set":{"banner": None}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"colour": None}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"banner": None}}) else: pass - embed = discord.Embed(colour=0xa82021, title="Which chest would you like to buy?", description="[1] Restaurant Colour Chest - $200 <:CustomChest1:655981726077550615>\n[2] Restaurant Banner Chest - $400 <:CustomChest2:655981738148888598>") - embed.set_footer(text="You have 90 seconds to reply with the number") - await ctx.send(embed=embed) - choice = await self.bot.wait_for('message', check=nc, timeout=90) - if int(choice.content) == 1: - if post['money'] < 200: - await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") - else: - await self.take_money(ctx.author.id, 200) - rn = random.randint(1,3) - if not rn == 1: - chosen = rnd(items.colours['common']) - chosen['rarity'] = "Common" - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['colour']} (Common)") - embed.set_thumbnail(url="http://pixelartmaker.com/art/5dd01d7e459201b.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['colour']} to use it.") - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Colour Chest and received...') - else: - chosen = rnd(items.colours['uncommon']) - chosen['rarity'] = "Uncommon" - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['colour']} (Uncommon)") - embed.set_thumbnail(url="http://pixelartmaker.com/art/5dd01d7e459201b.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['colour']} to use it.") - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Colour Chest and received...') - elif int(choice.content) == 2: - if post['money'] < 400: + embed = discord.Embed(colour=0x8980d9, title="Which chest would you like to buy?", description="**[1] <:CustomChest1:655981726077550615> Restaurant Color Chest** - <:BistroBux:1324936072760786964>200\n**[2] <:CustomChest2:655981738148888598> Restaurant Banner Chest** - <:BistroBux:1324936072760786964>300") + embed.set_footer(text="You have 90 seconds to choose a number.") + t_msg = None + async def rcb_callback(interaction, choice): + await interaction.response.defer() + if choice == 1: + if post['money'] < 200: await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") else: - await self.take_money(ctx.author.id, 400) - banners_had = [] - for x in post['inventory']: - if 'banner' in x: - banners_had.append(x['banner']['name']) - else: - pass - rn = ['common', 'common', 'common', 'common', 'common', 'common', 'uncommon', 'uncommon', 'uncommon', 'rare'] - cr = rnd(rn) - if cr == 'common': - chosen = rnd(items.banners['common']) - chosen['rarity'] = "Common" - if chosen['name'] in banners_had: - embed = discord.Embed(colour=0xa82021, description=f"~~{chosen['name']} ({chosen['rarity']})~~\n\n**Duplicate!** You got $200 because this banner is already in your inventory.") - embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - await self.add_money(user=ctx.author.id, count=200) - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') - else: - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['name']} (Common) [View banner]({chosen['url']})") - embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['name']} to use it.") - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') - elif cr == 'uncommon': - chosen = rnd(items.banners['uncommon']) + await self.take_money(ctx.author.id, 200) + owned_colors = {item['colour']['colour'] for item in post['inventory'] if 'colour' in item} + colors_f = { + rarity: [color for color in items.colours[rarity] if color['colour'] not in owned_colors] + for rarity in items.colours + } + rn = random.randint(1,3) + if not colors_f['common']: + rn = 1 + if not rn == 1: + chosen = rnd(colors_f['common']) chosen['rarity'] = "Common" - if chosen['name'] in banners_had: - embed = discord.Embed(colour=0xa82021, description=f"~~{chosen['name']} ({chosen['rarity']})~~\n\n**Duplicate!** You got $200 because this banner is already in your inventory.") + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) + embed = discord.Embed(colour=0x8980d9, description=f"{chosen['colour']} (Common)") + embed.set_thumbnail(url="http://pixelartmaker.com/art/5dd01d7e459201b.png") + embed.set_footer(text=f"Do b.inventory to check your inventory, or b.use {chosen['colour']} to use it.") + await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Colour Chest and received...') + else: + chosen = rnd(colors_f['uncommon']) + chosen['rarity'] = "Uncommon" + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"colour": chosen}}}) + embed = discord.Embed(colour=0x8980d9, description=f"{chosen['colour']} (Uncommon)") + embed.set_thumbnail(url="http://pixelartmaker.com/art/5dd01d7e459201b.png") + embed.set_footer(text=f"do b.inventory to check your inventory, or b.use {chosen['colour']} to use it.") + await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Colour Chest and received...') + elif choice == 2: + if post['money'] < 300: + await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") + else: + await self.take_money(ctx.author.id, 300) + owned_banners = {item['banner']['name'] for item in post['inventory'] if 'banner' in item} + banners_f = { + rarity: [banner for banner in items.banners[rarity] if banner['name'] not in owned_banners] + for rarity in ['common', 'uncommon', 'rare'] + } + rn = ['common'] * 6 + ['uncommon'] * 3 + ['rare'] + cr = rnd(rn) + if cr == 'common': + chosen = rnd(banners_f['common']) + chosen['rarity'] = "Common" + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) + embed = discord.Embed(colour=0x8980d9, description=f"{chosen['name']} (Common) [View banner]({chosen['url']})") embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - await self.add_money(user=ctx.author.id, count=200) + embed.set_footer(text=f"do b.inventory to check your inventory, or b.use {chosen['name']} to use it.") await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') - else: - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['name']} (Uncommon) [View banner]({chosen['url']})") + elif cr == 'uncommon': + chosen = rnd(banners_f['uncommon']) + chosen['rarity'] = "Common" + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) + embed = discord.Embed(colour=0x8980d9, description=f"{chosen['name']} (Uncommon) [View banner]({chosen['url']})") embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['name']} to use it.") + embed.set_footer(text=f"do b.inventory to check your inventory, or b.use {chosen['name']} to use it.") await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') - elif cr == 'rare': - chosen = rnd(items.banners['rare']) - chosen['rarity'] = "Rare" - if chosen['name'] in banners_had: - embed = discord.Embed(colour=0xa82021, description=f"~~{chosen['name']} ({chosen['rarity']})~~\n\n**Duplicate!** You got $200 because this banner is already in your inventory.") + elif cr == 'rare': + chosen = rnd(banners_f['rare']) + chosen['rarity'] = "Rare" + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) + embed = discord.Embed(colour=0x8980d9, description=f"{chosen['name']} (Rare) [View banner]({chosen['url']})") embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - await self.add_money(user=ctx.author.id, count=200) + embed.set_footer(text=f"do b.inventory to check your inventory, or b.use {chosen['name']} to use it.") await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') else: - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": chosen}}}) - embed = discord.Embed(colour=0xa82021, description=f"{chosen['name']} (Rare) [View banner]({chosen['url']})") - embed.set_thumbnail(url="http://pixelartmaker.com/art/34fc7859370d585.png") - embed.set_footer(text=f"Do r!inventory to check your inventory, or r!use {chosen['name']} to use it.") - await ctx.send(embed=embed, content=f'{ctx.author.mention}, you opened a Profile Banner Chest and received...') - else: - pass + pass + if t_msg: + await t_msg.delete() + try: + await interaction.message.delete() + except: + pass + + btn1 = Button(label="1", custom_id="chc1", style=discord.ButtonStyle.primary) + btn2 = Button(label="2", custom_id="chc2", style=discord.ButtonStyle.primary) - else: - await ctx.send("<:RedTick:653464977788895252> That is not an option.") + + btn1.callback = lambda interaction: rcb_callback(interaction, 1) + btn2.callback = lambda interaction: rcb_callback(interaction, 2) + + view = View() + view.add_item(btn1) + view.add_item(btn2) + t_msg = await ctx.send(embed=embed, view=view) + @buy.command(aliases=['Food']) async def food(self, ctx): def nc(m): return m.author == ctx.message.author - post = db.market.find_one({"owner": ctx.author.id}) - embed = discord.Embed(colour=0xa82021, title="Which food item would you like to add to your menu?") - embed.set_footer(text="You have 90 seconds to reply with the number") - cn = 0 + post = await db.market.find_one({"owner": ctx.author.id}) + embed = discord.Embed(colour=0x8980d9, title="Which food item would you like to add to your menu?") + embed.set_footer(text="Click the button below to buy the item") desc = "" n = [] items = [] + no_items = False country = post['country'] - for x in post['items']: - items.append(x['name']) - for x in extra.extra[country]: - if x['name'] in items: - pass - else: - cn += 1 - n.append({str(cn):x}) + #for x in post['items']: + # items.append(x['name']) + filtered = [item for item in extra.extra[country] if item not in post['items']] + for i, x in enumerate(filtered): + if i == 0: + n.append({str(i):x}) sp = x['price'] - desc += f"[{cn}] {x['name']} | Selling Price: {sp}\n" - embed.description = f"All menu items cost $600\n{desc}. You must go in order." - await ctx.send(embed=embed) - choice = await self.bot.wait_for('message', check=nc, timeout=90) - ch = choice.content.replace("[", "").replace("]", "").replace("r!", "") - if post['money'] > 600: - if ch in n[0]: - name = n[0][ch]['name'] - await ctx.send(f'{ctx.author.mention}, Item {name} was added to your menu.') - await self.take_money(ctx.author.id, 600) - db.market.update_one({"owner": ctx.author.id}, {"$push": {"items":n[0][ch]}}) + desc += f"**Next Item**:\n{x['name']} | Selling Price: {sp}\n\n" else: - await ctx.send("<:RedTick:653464977788895252> That is not an option.") - else: - await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") - + n.append({str(i):x}) + sp = x['price'] + desc += f"* {x['name']} | Selling Price: {sp}\n" + if not n: + desc = "*No more extra menu items to buy...*" + embed.description = f"Each menu item costs <:BistroBux:1324936072760786964>500. You must buy them in the order.\n\n{desc}" + food_msg = None + async def buy_callback(interaction): + await interaction.response.defer(ephemeral=True) + name = n[0]['0']['name'] + await self.take_money(ctx.author.id, 500) + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"items":n[0]['0']}}) + await interaction.followup.send(f'{ctx.author.mention}, Item **{name}** was added to your menu.', ephemeral=True) + if food_msg: + await food_msg.delete() + try: + await interaction.message.delete() + except: + pass + + buybtn = Button(label="Buy Next Item", custom_id="buy_btn", style=discord.ButtonStyle.primary) + buybtn.callback = buy_callback + view = View() + view.add_item(buybtn) + if post['money'] < 500 or not n: + buybtn.disabled = True + food_msg = await ctx.send(embed=embed, view=view) + @commands.group(aliases=['settings', 'Set', 'Settings']) @commands.cooldown(1, 4, commands.BucketType.user) async def set(self, ctx): if ctx.invoked_subcommand is None: - embed = discord.Embed(colour=0xa82021, title="'Set' Command Group", description="`r!set logo` - **Set Restaurant logo**\n`r!set notifications` - **Set notifications for your Restaurant**\n`r!set description` - **Set Restaurant description**\n`r!set name` - **Set Restaurant name**\n`r!set price` - **Set the price of an item**\n`r!set item` - **Set the price of your custom item (Level 3+)**\n`r!set dine` - **Set your dine message (Level 5+)**") + embed = discord.Embed(colour=0x8980d9, title="'Set' Command Group", description="`b.set logo` - **Set Restaurant logo**\n`b.set notifications` - **Set notifications for your Restaurant**\n`b.set description` - **Set Restaurant description**\n`b.set name` - **Set Restaurant name**\n`b.set special` - **Set your specialty item**\n`b.set item` - **Set your custom item (Level 3+)**\n`b.set dine` - **Set your dine message (Level 5+)**\n`b.set banner` - **Set a custom banner (Level 6+)**") await ctx.send(embed=embed) self.bot.get_command("set").reset_cooldown(ctx) + + @set.command(aliases=['Special']) + async def special(self, ctx): + post = await db.market.find_one({"owner": ctx.author.id}) + if not post: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Do `b.start` to start one.") + view = self.DropdownView(ctx, post, cog=self) + embed = discord.Embed(colour=0x8980d9, description="Select a food item to set it as your special:") + msg = await ctx.send(embed=embed, view=view) @set.command(aliases=['Notifications', 'notifs']) async def notifications(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) if not 'notifications' in post: - db.market.update_one({"owner": ctx.author.id}, {"$set": {"notifications": True}}) - await ctx.send("Notifications turned on.") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"notifications": True}}) + await ctx.send("<:CheckMark:1330789181470937139> Notifications turned on.") else: if post['notifications'] == False: - db.market.update_one({"owner": ctx.author.id}, {"$set": {"notifications": True}}) - await ctx.send("Notifications turned on.") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"notifications": True}}) + await ctx.send("<:CheckMark:1330789181470937139> Notifications turned on.") elif post['notifications'] == True: - db.market.update_one({"owner": ctx.author.id}, {"$set": {"notifications": False}}) - await ctx.send("Notifications turned off.") + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"notifications": False}}) + await ctx.send("<:CheckMark:1330789181470937139> Notifications turned off.") else: pass @set.command(aliases=['dinemessage', 'Dine']) async def dine(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) def check(m): return m.author == ctx.message.author if post['level'] < 5: await ctx.send("<:RedTick:653464977788895252> You must be level 5 or higher to set a custom item!") else: - embed = discord.Embed(colour=0xa82021, description='What are you going to set your custom dine message? You must include COST and ITEM in your message, and it must be 200 characters or less.\n\nExample: `You\'ve ordered ITEM for $COST! Have a good day!`') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Custom Item Creation") + embed = discord.Embed(colour=0x8980d9, description='What are you going to set your custom dine message? You must include COST and ITEM in your message, and it must be 200 characters or less.\n\nExample: `You\'ve ordered ITEM for <:BistroBux:1324936072760786964>COST! Have a good day!`') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Custom Item Creation") embed.set_footer(text="You have 90 seconds to reply") await ctx.send(embed=embed) msg = await self.bot.wait_for('message', check=check, timeout=90) dine = msg.content newmsg = dine.replace("nigg", "n*gg").replace("fag", "f*g").replace("fuck", "f*ck").replace("penis", "p*nis").replace("vagin", "v*gin") if len(newmsg) > 200: - failed = discord.Embed(colour=0xa82021, description="Dine messages must be 200 characters or less") + failed = discord.Embed(colour=0x8980d9, description="Dine messages must be 200 characters or less") failed.set_author(name="Creation Failed.") await ctx.send(embed=failed) elif not "COST" in newmsg or not "ITEM" in newmsg: - failed = discord.Embed(colour=0xa82021, description="You must include both COST and ITEM in your message! This makes the user know what they bought and how much it was!\n\nYou input: You bought a ITEM for $COST!\nDine message: You bought a Pizza for $5!") + failed = discord.Embed(colour=0x8980d9, description="You must include both COST and ITEM in your message! This makes the user know what they bought and how much it was!\n\nYou input: You bought a ITEM for <:BistroBux:1324936072760786964>COST!\nDine message: You bought a Pizza for <:BistroBux:1324936072760786964>5!") failed.set_author(name="Creation Failed.") await ctx.send(embed=failed) else: - embed = discord.Embed(colour=0xa82021, description=f'Perfect! Your dine message has been set!') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Custom Item Creation") + embed = discord.Embed(colour=0x8980d9, description=f'Perfect! Your dine message has been set!') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Custom Item Creation") await ctx.send(embed=embed) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"dinemsg": newmsg}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"dinemsg": newmsg}}) @set.command(name="item", aliases=['custom', 'customitem', 'Item']) async def _item(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) def check(m): return m.author == ctx.message.author if "customitem" in post: @@ -567,8 +1105,8 @@ def check(m): elif post['level'] < 3: await ctx.send("<:RedTick:653464977788895252> You must be level 3 or higher to set a custom item!") else: - embed = discord.Embed(colour=0xa82021, description='What are you going to name your custom item? It cannot be longer than 14 characters.') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Custom Item Creation") + embed = discord.Embed(colour=0x8980d9, description='What are you going to name your custom item? It cannot be longer than 14 characters.') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Custom Item Creation") embed.set_footer(text="You have 90 seconds to reply") await ctx.send(embed=embed) msg = await self.bot.wait_for('message', check=check, timeout=90) @@ -579,37 +1117,37 @@ def check(m): string.append(x.capitalize()) newitem = " ".join(string) if len(newitem) > 14: - failed = discord.Embed(colour=0xa82021, description="Item name must be 14 characters or less") + failed = discord.Embed(colour=0x8980d9, description="Item name must be 14 characters or less") failed.set_author(name="Creation Failed.") await ctx.send(embed=failed) else: - embed = discord.Embed(colour=0xa82021, description=f'Perfect! How much should "{newitem}" cost? It must be between $1 and $10') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Custom Item Creation") + embed = discord.Embed(colour=0x8980d9, description=f'Perfect! How much should "{newitem}" cost? It must be between <:BistroBux:1324936072760786964>1 and <:BistroBux:1324936072760786964>10') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Custom Item Creation") embed.set_footer(text="You have 90 seconds to reply") await ctx.send(embed=embed) msg = await self.bot.wait_for('message', check=check, timeout=90) price = int(msg.content) if price > 10 or price < 1: - failed = discord.Embed(colour=0xa82021, description="Item cost must be between $1 and $10!") + failed = discord.Embed(colour=0x8980d9, description="Item cost must be between <:BistroBux:1324936072760786964>1 and <:BistroBux:1324936072760786964>10!") failed.set_author(name="Creation Failed.") await ctx.send(embed=failed) else: - embed = discord.Embed(colour=0xa82021, description=f'Awesome! Menu item, "{newitem}", has been added to your menu!') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Custom Item Creation") + embed = discord.Embed(colour=0x8980d9, description=f'Awesome! Menu item, "{newitem}", has been added to your menu!') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Custom Item Creation") await ctx.send(embed=embed) - db.market.update_one({"owner": ctx.author.id}, {"$push":{"items": {"name": newitem, "price": price, "stock": 0, "sold": 0}}}) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"customitem": True}}) + await db.market.update_one({"owner": ctx.author.id}, {"$push":{"items": {"name": newitem, "price": price, "stock": 0, "sold": 0}}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"customitem": True}}) @set.command(aliases=['Logo', 'image', 'icon']) async def logo(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) def react(reaction, user): return user != ctx.me and str(reaction.emoji) == '✅' or str(reaction.emoji) == '❎' def nc(m): return m.author == ctx.message.author - embed = discord.Embed(colour=0xa82021, description="To keep NSFW off of Restaurant Bot, staff members must review every logo.\n\nReply with the image URL for your logo.") + embed = discord.Embed(colour=0x8980d9, description="To keep NSFW off of Restaurant Bot, staff members must review every logo.\n\nReply with the image URL for your logo.") embed.set_footer(text="You have 90 seconds to reply") msg = await ctx.send(embed=embed) link = await self.bot.wait_for('message', check=nc, timeout=90) @@ -618,15 +1156,15 @@ def nc(m): except: pass if link.content.startswith('http') and link.content.endswith('.jpg') or link.content.startswith('http') and link.content.endswith('.png') or link.content.startswith('http') and link.content.endswith('.jpeg') or link.content.startswith('http') and link.content.endswith('.gif'): - embed = discord.Embed(colour=0xa82021, description="Perfect! Your image has been sent to the Restaurant Bot staff team for reviewal.\n\n This process may take up to 24 hours. But don't worry, it will probably be even quicker.") + embed = discord.Embed(colour=0x8980d9, description="Perfect! Your image has been sent to the Restaurant Bot staff team for reviewal.\n\n This process may take up to 24 hours. But don't worry, it will probably be even quicker.") embed.set_footer(text="Too many NSFW requests can end up in a ban from Restaurant Bot!") await msg.edit(embed=embed) se = discord.Embed(description=link.content) se2 = discord.Embed() - se.set_footer(icon_url=ctx.author.avatar_url_as(format='png'), text=f"{ctx.author} | {ctx.author.id}") + se.set_footer(icon_url=ctx.author.avatar.url, text=f"{ctx.author} | {ctx.author.id}") se.set_thumbnail(url=link.content) - se2.set_footer(icon_url=ctx.author.avatar_url_as(format='png'), text=f"{ctx.author} | {ctx.author.id}") + se2.set_footer(icon_url=ctx.author.avatar.url, text=f"{ctx.author} | {ctx.author.id}") se2.set_thumbnail(url=link.content) sem = await self.bot.get_channel(650994466307571714).send(embed=se) await sem.add_reaction('✅') @@ -637,21 +1175,90 @@ def nc(m): se2.description = '*Logo accepted*' await sem.edit(embed=se2) await ctx.author.send("Your logo has been accepted!") - db.market.update_one({"owner": ctx.author.id}, {"$set":{"logo_url": link.content}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"logo_url": link.content}}) + await self.get_award(ctx.author.id, "logo_approved") else: se2.description = '*Logo denied*' await sem.edit(embed=se2) await ctx.author.send("Your logo has been denied.") else: - embed = discord.Embed(colour=0xa82021, description="That is not a valid link. It must end with `.png`, `.jpg`, `.jpeg`, or `.gif`.") + embed = discord.Embed(colour=0x8980d9, description="That is not a valid link. It must end with `.png`, `.jpg`, `.jpeg`, or `.gif`.") embed.set_author(name="Failed.") await msg.edit(embed=embed) + @set.command(aliases=['Banner']) + async def banner(self, ctx): + post = await db.market.find_one({"owner": ctx.author.id}) + patrons = await db.utility.find_one({'utility': 'patrons'}) + def react(reaction, user): + return user != ctx.me and str(reaction.emoji) == '✅' or str(reaction.emoji) == '❎' + def nc(m): + return m.author == ctx.message.author + if not post: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`.") + else: + if post['level'] > 5 or patrons and any(patrons.get(key) and ctx.author.id in patrons[key] for key in ['silver', 'gold', 'diamond']): + embed = discord.Embed(colour=0x8980d9, description="To keep NSFW off of Restaurant Bot, staff members must review every banner.\n\nReply with the image URL for your banner.") + embed.set_footer(text="You have 90 seconds to reply") + msg = await ctx.send(embed=embed) + link = await self.bot.wait_for('message', check=nc, timeout=90) + try: + await link.delete() + except: + pass + ctx.typing() + embed = discord.Embed(colour=0x8980d9) + embed.set_footer(text="Loading...") + await msg.edit(embed=embed) + ar = await self.get_image_dimensions(link.content) + if not ar: + embed = discord.Embed(colour=0x8980d9, description="The image should have an aspect ratio between 3:1 and 7:1. ") + embed.set_author(name="Failed.") + await msg.edit(embed=embed) + else: + if ar == 0: + embed = discord.Embed(colour=0x8980d9, description="That is not a valid link, I was unable to insert it. ") + embed.set_author(name="Failed.") + await msg.edit(embed=embed) + elif not 3 <= ar <= 7: + embed = discord.Embed(colour=0x8980d9, description="The image should have an aspect ratio between 3:1 and 7:1. ") + embed.set_author(name="Failed.") + await msg.edit(embed=embed) + else: + embed = discord.Embed(colour=0x8980d9, description="Perfect! Your image has been sent to the Restaurant Bot staff team for reviewal.\n\n This process may take up to 24 hours. But don't worry, it will probably be even quicker.") + embed.set_footer(text="Too many inappropriate requests can end up in a ban from Restaurant Bot!") + await msg.edit(embed=embed) + + se = discord.Embed(description=link.content) + se2 = discord.Embed() + se.set_footer(icon_url=ctx.author.avatar.url, text=f"{ctx.author} | {ctx.author.id}") + se.set_thumbnail(url=link.content) + se2.set_footer(icon_url=ctx.author.avatar.url, text=f"{ctx.author} | {ctx.author.id}") + se2.set_thumbnail(url=link.content) + sem = await self.bot.get_channel(650994466307571714).send(embed=se) + await sem.add_reaction('✅') + await sem.add_reaction('❎') + await asyncio.sleep(2) + reaction, user = await self.bot.wait_for('reaction_add', check=react) + if reaction.emoji == '✅': + se2.description = '*Banner accepted*' + await sem.edit(embed=se2) + await ctx.author.send("Your logo has been accepted!") + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"logo_url": link.content}}) + await self.get_award(ctx.author.id, "set_banner") + else: + se2.description = '*Banner denied*' + await sem.edit(embed=se2) + await ctx.author.send("**Your logo has been denied.** Our reviewers are not very strict, so this could have been an error! If you believe so, visit our support server: https://discord.gg/BCRtw7c") + else: + await ctx.send("Your restaurant must be at least level 6 to set a custom banner. You can purchase a set one with `r!buy custom`.") + + @set.command(aliases=['Description', 'desc']) async def description(self, ctx): def nc(m): return m.author == ctx.message.author - embed = discord.Embed(colour=0xa82021, description="Descriptions must me 130 characters or less.\n\nReply with your desired description.") + embed = discord.Embed(colour=0x8980d9, description="Descriptions must me 130 characters or less.\n\nReply with your desired description.") embed.set_footer(text="You have 90 seconds to reply") msg = await ctx.send(embed=embed) desc = await self.bot.wait_for('message', check=nc, timeout=90) @@ -660,21 +1267,22 @@ def nc(m): except: pass if len(desc.content) > 130: - embed = discord.Embed(colour=0xa82021, description="Description is more than 130 characters.") + embed = discord.Embed(colour=0x8980d9, description="Description is more than 130 characters.") embed.set_author(name="Failed.") await msg.edit(embed=embed) else: - embed = discord.Embed(colour=0xa82021, description="Great! Your restaurant's description has been set!") + embed = discord.Embed(colour=0x8980d9, description="Great! Your restaurant's description has been set!") await msg.edit(embed=embed) - db.market.update_one({"owner": ctx.author.id}, {"$set":{"description": desc.content}}) + desc_stripped = str(desc.content).replace('nigg','n*gg').replace('Nigg','N*gg').replace('NIGG','N*GG').replace("fag", "f*g").replace("Fag", "F*g").replace("FAG", "F*G") + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"description": desc_stripped}}) @set.command(aliases=['Name']) async def name(self, ctx): def nc(m): return m.author == ctx.message.author - post = db.market.find_one({"owner": int(ctx.author.id)}) + post = await db.market.find_one({"owner": int(ctx.author.id)}) if post: - embed = discord.Embed(colour=0xa82021, description="Names must me 36 characters or less.\n\nReply with your desired name.") + embed = discord.Embed(colour=0x8980d9, description="Names must me 36 characters or less.\n\nReply with your desired name.") embed.set_footer(text="You have 90 seconds to reply") msg = await ctx.send(embed=embed) name = await self.bot.wait_for('message', check=nc, timeout=90) @@ -683,59 +1291,16 @@ def nc(m): except: pass if len(name.content) > 130: - embed = discord.Embed(colour=0xa82021, description="Name is more than 36 characters.") + embed = discord.Embed(colour=0x8980d9, description="Name is more than 36 characters.") embed.set_author(name="Failed.") await msg.edit(embed=embed) else: - embed = discord.Embed(colour=0xa82021, description="Awesome! Your restaurant's name has been set!") + embed = discord.Embed(colour=0x8980d9, description="Awesome! Your restaurant's name has been set!") await msg.edit(embed=embed) new_name = str(name.content).replace('nigg','n*gg').replace('Nigg','N*gg').replace('NIGG','N*GG') - db.market.update_one({"owner": ctx.author.id}, {"$set":{"name": new_name}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"name": new_name}}) else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") - - @set.command(aliases=['Price']) - async def price(self, ctx): - def nc(m): - return m.author == ctx.message.author - post = db.market.find_one({"owner": int(ctx.author.id)}) - if post: - embed = discord.Embed(colour=0xa82021, description="What item would you like to change the price of?") - embed.set_footer(text="You have 90 seconds to reply") - msg = await ctx.send(embed=embed) - item = await self.bot.wait_for('message', check=nc, timeout=90) - try: - await item.delete() - except: - pass - it = None - for x in post['items']: - if x['name'].lower() == item.content.lower(): - it = x - if not it: - embed = discord.Embed(colour=0xa82021, description=f"That item is not on your menu. Check it with `r!menu {post['name']}`") - embed.set_author(name="Failed.") - await msg.edit(embed=embed) - else: - embed = discord.Embed(colour=0xa82021, description="What price do you want to set it at?\n\nIt may not be less than $1 or more than $45") - await msg.edit(embed=embed) - #db.market.update_one({"owner": ctx.author.id}, {"$set":{"name": name.content}}) - price = await self.bot.wait_for('message', check=nc, timeout=90) - try: - await price.delete() - except: - pass - if not price.content.isdigit() or int(price.content) > 45 or int(price.content) < 1: - embed = discord.Embed(colour=0xa82021, description=f"Prices may not be less than $1 or more than $45") - embed.set_author(name="Failed.") - await msg.edit(embed=embed) - else: - embed = discord.Embed(colour=0xa82021, description="Amazing! The price has been set.") - await msg.edit(embed=embed) - db.market.update_one({"owner": ctx.author.id}, {"$pull":{"items": it}}) - db.market.update_one({"owner": ctx.author.id}, {"$push":{"items":{"name": it['name'],"price": int(price.content),"stock": it['stock'],"sold": it['sold']}}}) - else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`.") @set.command(aliases=['Stock']) @commands.is_owner() @@ -743,8 +1308,8 @@ async def stock(self, ctx): # not gonna use def nc(m): return m.author == ctx.message.author - post = db.market.find_one({"owner": int(ctx.author.id)}) - embed = discord.Embed(colour=0xa82021, description="What item would you like to stock?\n\nType all to stock all items.") + post = await db.market.find_one({"owner": int(ctx.author.id)}) + embed = discord.Embed(colour=0x8980d9, description="What item would you like to stock?\n\nType all to stock all items.") embed.set_footer(text="You have 90 seconds to reply") msg = await ctx.send(embed=embed) item = await self.bot.wait_for('message', check=nc, timeout=90) @@ -757,7 +1322,7 @@ def nc(m): if x['name'].lower() == item.content.lower(): it = x if not it: - embed = discord.Embed(colour=0xa82021, description=f"That item is not on your menu. Check it with `r!menu {post['name']}`") + embed = discord.Embed(colour=0x8980d9, description=f"That item is not on your menu. Check it with `b.menu {post['name']}`") embed.set_author(name="Failed.") await msg.edit(embed=embed) else: @@ -767,37 +1332,38 @@ def nc(m): sp = it['price'] - 2 else: sp = it['price'] - 3 - embed = discord.Embed(colour=0xa82021, description=f"How many would you like to stock?\n\nStocking this item once would cost you ${sp}.") + embed = discord.Embed(colour=0x8980d9, description=f"How many would you like to stock?\n\nStocking this item once would cost you <:BistroBux:1324936072760786964>{sp}.") await msg.edit(embed=embed) - #db.market.update_one({"owner": ctx.author.id}, {"$set":{"name": name.content}}) + #await db.market.update_one({"owner": ctx.author.id}, {"$set":{"name": name.content}}) price = await self.bot.wait_for('message', check=nc, timeout=90) try: await price.delete() except: pass if not price.content.isdigit() or int(price.content) > 45 or int(price.content) < 1: - embed = discord.Embed(colour=0xa82021, description=f"Prices may not be less than $1 or more than $45") + embed = discord.Embed(colour=0x8980d9, description=f"Prices may not be less than <:BistroBux:1324936072760786964>1 or more than <:BistroBux:1324936072760786964>45") embed.set_author(name="Failed.") await msg.edit(embed=embed) else: - embed = discord.Embed(colour=0xa82021, description="Amazing! The price has been set.") + embed = discord.Embed(colour=0x8980d9, description="Amazing! The price has been set.") await msg.edit(embed=embed) - db.market.update_one({"owner": ctx.author.id}, {"$pull":{"items": it}}) - db.market.update_one({"owner": ctx.author.id}, {"$push":{"items":{"name": it['name'],"price": int(price.content),"stock": it['stock'],"sold": it['sold']}}}) + await db.market.update_one({"owner": ctx.author.id}, {"$pull":{"items": it}}) + await db.market.update_one({"owner": ctx.author.id}, {"$push":{"items":{"name": it['name'],"price": int(price.content),"stock": it['stock'],"sold": it['sold']}}}) @commands.command(aliases=['Random', 'rr']) @commands.cooldown(1, 2, commands.BucketType.user) async def random(self, ctx, user:discord.User=None): if not user: user = ctx.author - rndm = random.randint(1, db.market.find().count()) + rn_count = await db.market.count_documents({}) + rndm = random.randint(1, rn_count) try: - p = db.market.find().limit(2).skip(rndm).next() + p = await db.market.find().limit(2).skip(rndm).next() if p['owner'] == ctx.author.id: - if db.market.find().count() == rndm: - post = db.market.find().limit(1).skip(rndm-1).next() + if rn_count == rndm: + post = await db.market.find().limit(1).skip(rndm-1).next() else: - post = db.market.find().limit(1).skip(rndm+1).next() + post = await db.market.find().limit(1).skip(rndm+1).next() else: post = p except StopIteration: @@ -832,14 +1398,14 @@ def react(reaction, user): list = sorted(ldi, key=lambda x: x['sold'], reverse=True) embed = discord.Embed(description=post['description']) embed.set_author(icon_url=self.flags[country], name=post['name']) - embed.add_field(name=":notepad_spiral: Menu", value=post['items'][0]['name'] + ", " + post['items'][1]['name'] + ", " + post['items'][2]['name'] + f"... To view the full menu, do `r!menu {post['name']}`") + embed.add_field(name=":notepad_spiral: Menu", value=post['items'][0]['name'] + ", " + post['items'][1]['name'] + ", " + post['items'][2]['name'] + f"... To view the full menu, do `b.menu {post['name']}`") embed.add_field(name=":bar_chart: Experience", value=format(post['exp'], ",d")) #embed.add_field(name=":chart_with_upwards_trend: Most Sold item", value=list[0]['name']) - embed.add_field(name=":moneybag: Average Price", value="$" + str(average)) + embed.add_field(name=":moneybag: Average Price", value="<:BistroBux:1324936072760786964>" + str(average)) embed.add_field(name=":page_with_curl: Rating", value=stars) embed.add_field(name=":name_badge: Owner", value=str(self.bot.get_user(post['owner'])).replace("None", "Unknown")) if not post['logo_url']: - embed.set_thumbnail(url=ctx.me.avatar_url_as(format='png')) + embed.set_thumbnail(url=ctx.bot.user.avatar.url) else: embed.set_thumbnail(url=post['logo_url']) embed.set_footer(text=f"Random Restaurant | Last Stock: {post['laststock']}") @@ -849,15 +1415,19 @@ def react(reaction, user): @commands.command(aliases=['Slots', 'slot']) @commands.cooldown(1, 3, commands.BucketType.user) async def slots(self, ctx, bet:int = None): - on = False - if on: - posts = db.market.find_one({"owner": ctx.author.id}) + await ctx.typing() + posts = await db.market.find_one({"owner": ctx.author.id}) + patrons = await db.utility.find_one({"utility": "patrons"}) + if not posts: + await ctx.send("<:RedTick:653464977788895252> You do not have a restaurant! Start one with `b.start`") + if patrons and any(patrons.get(key) and ctx.author.id in patrons[key] for key in ['silver', 'gold', 'diamond']): + posts = await db.market.find_one({"owner": ctx.author.id}) if bet == None: - await ctx.send('<:RedTick:653464977788895252> Please provide your bet with the command. Example: `r!slots 50`') + await ctx.send('<:RedTick:653464977788895252> Please provide your bet with the command. Example: `b.slots 50`') elif not int(posts['money']) >= int(bet) or int(posts['money']) == int(bet): await ctx.send('<:RedTick:653464977788895252> You don\'t have enough money.') - elif int(bet) < 25: - await ctx.send('<:RedTick:653464977788895252> Your bet must be above $25.') + elif int(bet) < 20: + await ctx.send('<:RedTick:653464977788895252> Your bet must be above <:BistroBux:1324936072760786964>20.') else: emojis = [':ramen:', ':cherries:', ':grapes:', ':banana:', ':poultry_leg:', ':pizza:', ':taco:', ':hamburger:', ':hotdog:'] fruits = [':cherries:', ':grapes:', ':banana:'] @@ -872,51 +1442,75 @@ async def slots(self, ctx, bet:int = None): i = random.choice(emojis) if a == b == c: if a == ':ramen:': - won = bet*6 - slot1 = discord.Embed(colour=0xa82021, description=f"JACKPOT! You've won ${won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") + won = bet*5 + slot1 = discord.Embed(colour=0x8980d9, description=f"JACKPOT! You've won <:BistroBux:1324936072760786964>{won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") else: - won = bet*3 - slot1 = discord.Embed(colour=0xa82021, description=f"Amazing! You've won ${won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") + won = bet*2 + slot1 = discord.Embed(colour=0x8980d9, description=f"Amazing! You've won <:BistroBux:1324936072760786964>{won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") await ctx.send(embed=slot1, content=f"{ctx.author.mention}, you've used some of your Restaurant income on a slot machine...") - await self.add_money(user=ctx.author.id, count=won) + await self.add_money(user=ctx.author.id, count=won, check_tasks=True) elif a == b or a == c or b == c: won = bet*2 - slot2 = discord.Embed(colour=0xa82021, description=f"Nice! You've won ${won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") + slot2 = discord.Embed(colour=0x8980d9, description=f"Nice! You've won <:BistroBux:1324936072760786964>{won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") await ctx.send(embed=slot2, content=f"{ctx.author.mention}, you've used some of your Restaurant income on a slot machine...") - await self.add_money(user=ctx.author.id, count=won) + await self.add_money(user=ctx.author.id, count=won, check_tasks=True) else: if a in fruits and b in fruits and c in fruits: - won = bet*3 - slot2 = discord.Embed(colour=0xa82021, description=f"Fruit Bonanza! You've won ${won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") - await ctx.send(embed=slot2, content=f"{ctx.author.mention}, you've used some of your Restaurant income on a slot machine...") - await self.add_money(user=ctx.author.id, count=won) + won = bet*2 + slot2 = discord.Embed(colour=0x8980d9, description=f"Fruit Bonanza! You've won <:BistroBux:1324936072760786964>{won}!\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") + await ctx.send(embed=slot2, content=f"{ctx.author.mention}, you used some of your Restaurant income on a slot machine...") + await self.add_money(user=ctx.author.id, count=won, check_tasks=True) else: - slot3 = discord.Embed(colour=0xa82021, description=f"Aw! You didn't win anything.\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") - await ctx.send(embed=slot3, content=f"{ctx.author.mention}, you've used some of your Restaurant income on a slot machine...") + slot3 = discord.Embed(colour=0x8980d9, description=f"Aw! You didn't win anything.\n\n{d} {e} {f} ` `\n{a} {b} {c} `<`\n{g} {h} {i} ` `") + await ctx.send(embed=slot3, content=f"{ctx.author.mention}, you used some of your Restaurant income on a slot machine...") await self.take_money(user=ctx.author.id, count=bet) else: - await ctx.send("This command is currently disabled for all users.") + await ctx.send("<:RedTick:653464977788895252> You must be a patron to use this command! Do `b.donation` for more info.") @commands.command(aliases=['Clean']) - @commands.cooldown(1, 300, commands.BucketType.user) async def clean(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) - to_clean = [{'name': 'sink', 'exp': 4}, {'name': 'oven', 'exp': 8}, {'name': 'counters', 'exp': 12}, {'name': 'floors', 'exp': 16}, {'name': 'bathrooms', 'exp': 20}, {'name': 'kitchen', 'exp': 24}] - if post: - rn = rnd(to_clean) - count = await self.add_exp(user=ctx.author.id, count=rn['exp']) - await ctx.send(f"{ctx.author.mention}, You cleaned the {rn['name']} and earned {count} EXP.") + post = await db.market.find_one({"owner": ctx.author.id}) + if not post: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`.") + return + if 'agility' in post['stones']: + cd_sec = 130 else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") + cd_sec = 95 + on_cd, remaining = await self.dynamic_cd(ctx.author.id, "clean", cd_sec) + if on_cd: + c_min = int(remaining) // 60 + c_sec = int(remaining) % 60 + m_l = "m " + if not c_min: + c_min = "" + m_l = "" + await ctx.send(f"<:RedTick:653464977788895252> You are on cooldown! Please wait **{c_min}{m_l}{c_sec}s**.") + return + to_clean = [{'name': 'sink', 'exp': 6}, {'name': 'oven', 'exp': 12}, {'name': 'counters', 'exp': 16}, {'name': 'floors', 'exp': 18}, {'name': 'bathrooms', 'exp': 22}, {'name': 'kitchen', 'exp': 26}] + rn = rnd(to_clean) + count = await self.add_exp(user=ctx.author.id, count=rn['exp']) + await ctx.send(f"{ctx.author.mention}, You cleaned the {rn['name']} and earned {count} EXP.") + if "clean_onefifty" in post['tasks']: + user = post + ix = user['tasks'].index("clean_onefifty") + if user['task_list'][ix]['completed']+1 == user['task_list'][ix]['total']: + await ctx.author.send(f"You have completed the **{user['task_list'][ix]['description']}** task. You have been awarded **{user['task_list'][ix]['rewards']} EXP**.") + await self.add_exp(user=ctx.author.id, count=user['task_list'][ix]['rewards'], multiplier=False) + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "clean_onefifty"},{"$inc": {"task_list.$.completed": 1}}) + else: + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "clean_onefifty"},{"$inc": {"task_list.$.completed": 1}}) @commands.command(aliases=['Fish']) @commands.cooldown(1, 120, commands.BucketType.user) async def fish(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) - to_fish = [{'name': 'a bag of sugar', 'money': 4, 'exp': 5}, {'name': 'some eggs', 'money': 3, 'exp': 3}, {'name': 'a fish', 'money': 11, 'exp': 17}, {'name': 'some rice', 'money': 3, 'exp': 19}, {'name': 'a bag of potatoes', 'money': 6, 'exp': 10}, {'name': 'a few apples', 'money': 7, 'exp': 11}, {'name': 'two bags of carrots', 'money': 8, 'exp': 12}, {'name': 'a bag of flour', 'money': 4, 'exp': 16}, {'name': 'a can of salt', 'money': 7, 'exp': 16}] + post = await db.market.find_one({"owner": ctx.author.id}) + to_fish = [{'name': 'a bag of sugar', 'money': 4, 'exp': 10}, {'name': 'some eggs', 'money': 3, 'exp': 8}, {'name': 'a fish', 'money': 11, 'exp': 19}, {'name': 'a bag of rice', 'money': 3, 'exp': 21}, {'name': 'a bag of potatoes', 'money': 6, 'exp': 12}, {'name': 'an apple', 'money': 7, 'exp': 20}, {'name': 'two bags of carrots', 'money': 8, 'exp': 24}, {'name': 'a bag of flour', 'money': 4, 'exp': 18}, {'name': 'a can of salt', 'money': 7, 'exp': 16}, {'name': 'a worm', 'money': 2, 'exp': 3}, {'name': 'a candy wrapper', 'money': 2, 'exp': 12}, {'name': 'a bag of onions', 'money': 9, 'exp': 14}] if post: fish = False item = None + pole_broke = False + luck = post['luck'] for x in post['inventory']: if 'item' in x: if x['item'] == 'fish': @@ -926,173 +1520,404 @@ async def fish(self, ctx): pass else: pass - #if not fish: - #fish = False if not fish: - await ctx.send("You don't have a fishing rod. Buy one by saying `r!buy item` and then saying `1`.") + await ctx.send("You don't have a fishing rod. Buy one by saying `b.buy item` and then clicking `1`.") self.bot.get_command("fish").reset_cooldown(ctx) else: - rn = rnd(to_fish) - await self.add_exp(user=ctx.author.id, count=rn['exp']) - await self.add_money(user=ctx.author.id, count=rn['money']) - rn2 = random.randint(1, 10) - if rn2 == 10: - bmsg = "Unfortunately, your rod broke after you reeled in your rewards." - db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory": item}}) + if random.randint(1, 15) == 1: + frag = await self.add_rand_fragment(ctx.author.id) + if not frag: + await self.add_money(ctx.author.id, 120, check_tasks=True) + await ctx.send(f"{ctx.author.mention}, You threw your fishing rod out and received {bbux}120!") + else: + if frag == 'agility': + emoji = '<:AgilityFragment:1331502143760236574>' + elif frag == 'opportunity': + emoji = '<:OpportunityFragment:1331505178959937556>' + elif frag == 'endearing': + emoji = '<:EndearingFragment:1331823626080620574>' + elif frag == 'ambience': + emoji = '<:AmbienceFragment:1331825947036483675>' + await ctx.send(f"{ctx.author.mention}, you threw your fishing rod out and received a {emoji} **Fragment of {frag.capitalize()}**!") else: - bmsg = "" - await ctx.send(f"{ctx.author.mention}, You threw out your fishing rod and got {rn['name']} which earned you ${rn['money']} & {rn['exp']} EXP. {bmsg}") + rn = rnd(to_fish) + money = rn['money'] + exp = rn['exp'] + if 'fishing_boat' in post['bonuses']: + money*=1.3 + exp*=1.25 + money = round(money) + exp = round(exp) + await self.add_exp(user=ctx.author.id, count=exp) + await self.add_money(user=ctx.author.id, count=money, check_tasks=True) + if luck == 2: + rn2 = random.randint(1, 9) + if luck == 3: + rn2 = random.randint(1, 11) + if luck == 4: + rn2 = random.randint(1, 12) + if luck == 5: + rn2 = random.randint(1, 13) + if luck == 6: + rn2 = random.randint(1, 15) + if luck == 7: + rn2 = random.randint(1, 16) + if luck >= 8: + rn2 = random.randint(1, 18) + else: + rn2 = random.randint(1, 7) + if rn2 == 1: + bmsg = "Unfortunately, your rod broke after you reeled in your rewards." + db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory": item}}) + award = await self.get_award(ctx.author.id, "broken_pole") + pole_broke = True + else: + bmsg = "" + + await ctx.send(f"{ctx.author.mention}, You threw your fishing rod out and got **{rn['name']}** which earned you <:BistroBux:1324936072760786964>{money} & {exp} EXP. {bmsg}") + if pole_broke: + if award: + await ctx.send(f"Even though you broke your fishing pole, you received the {awards.awards["broken_pole"]["emoji"]} **Sad Fisherman** award! View awards with `b.awards`") else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`.") - @commands.command(aliases=['Cookt', 'Baket', 'baket']) - @commands.cooldown(1, 1, commands.BucketType.user)#cd 150 - async def cookt(self, ctx): + @commands.command(aliases=['Cook', 'Bake', 'bake']) + #@commands.cooldown(1, 90, commands.BucketType.user) + async def cook(self, ctx): def nc(m): - return m.author == ctx.author and m.channel == ctx.channel and m.content.lower().replace('r!', '') == 'stop' - post = db.market.find_one({"owner": ctx.author.id}) + return m.author == ctx.author and m.channel == ctx.channel and not m.content.startswith("r!menu") + post = await db.market.find_one({"owner": ctx.author.id}) + rating = 5 + rn = rnd([1,2]) + if post['luck'] == 2: + fire_chance = random.randint(1, 5) + elif post['luck'] == 3: + fire_chance = random.randint(1, 7) + elif post['luck'] == 4: + fire_chance = random.randint(1, 10) + elif post['luck'] == 5: + fire_chance = random.randint(1, 12) + elif post['luck'] == 6: + fire_chance = random.randint(1, 14) + elif post['luck'] == 7: + fire_chance = random.randint(1, 16) + elif post['luck'] > 7: + fire_chance = random.randint(1, 20) + else: + fire_chance = random.randint(1, 4) if post: - bar_int = 1 - country = post['country'] - cfood = rnd(food.food[country])['name'] - if cfood.startswith(("a", "e", "i", "o", "u")): - cfooda = "an " + cfood + if post['chef'] == 'm': + cd_sec = 80 + elif post['chef'] == 'w': + cd_sec = 60 else: - cfooda = "a " + cfood - done = False - desc = f"Say `stop` when the bar gets to red. Don't let it get burnt!\n\n`🟨`" - embed = discord.Embed(colour=0xa82021, description=desc) - embed.set_footer(text=f"You're cooking {cfooda}.") - msg = await ctx.send(embed=embed) - time.sleep(0.8) - bar_int = 1 - done = False - resp = await self.bot.wait_for('message', check=nc, timeout=30) - while bar_int <= 6: - if done: - pass + cd_sec = 100 + on_cd, remaining = await self.dynamic_cd(ctx.author.id, "cook", cd_sec) + if on_cd: + await ctx.send(f"<:RedTick:653464977788895252> You are on cooldown! Please wait **{int(remaining)} seconds**.") + return + if rn == 1: + country = post['country'] + flist = None + for c in food.can_burn: + if country in c: + flist = c + word = rnd(flist[country]) + if word.endswith("s"): + ltr_a = "" + else: + ltr_a = "a" + ws = word.split(" ") + new = [] + for x in ws: + li = list(x) + random.shuffle(li) + sw = "".join(li) + new.append(sw) + sw = " ".join(new) + na = word + + await ctx.send(f'{ctx.author.mention}, Unscramble this item on your menu to make it: `{sw}`') + b = time.perf_counter() + resp = await self.bot.wait_for('message', check=nc, timeout=120) + a = time.perf_counter() + tt = a-b + chance_of_fire = False + retry_allowed = True + if tt < 6: + if resp.content.lower().lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=27) + await ctx.send(f"Perfect! You made {ltr_a} delicious **{na}** in {round(tt)} seconds! You've earned **{c} EXP**.") + rating = 5 + else: + if retry_allowed and 'opportunity' in post['stones']: + await ctx.send(f"You failed to unscramble the letter, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! One more chance, what is `{sw}`?") + resp2 = await self.bot.wait_for('message', check=nc, timeout=120) + if resp2.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=7) + await ctx.send(f"I knew you could do it! You received **{c} EXP** for making {ltr_a} **{na}**.") + else: + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed again to unscramble the letters. You've earned **{c}** EXP for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + return + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned **{c} EXP** for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + elif tt < 8: + if resp.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=20) + await ctx.send(f"Amazing! You made {ltr_a} tasty **{na}** in {round(tt)} seconds! You've earned **{c} EXP**.") + rating = 5 + else: + if retry_allowed and 'opportunity' in post['stones']: + await ctx.send(f"You failed to unscramble the letter, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! One more chance, what is `{sw}`?") + resp2 = await self.bot.wait_for('message', check=nc, timeout=120) + if resp2.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=7) + await ctx.send(f"I knew you could do it! You received **{c} EXP** for making {ltr_a} **{na}**.") + else: + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed again to unscramble the letters. You've earned **{c}** EXP for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + return + c = await self.add_exp(user=ctx.author.id, count=1) + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned **{c} EXP** for making {ltr_a} terrible **{na}**.") + rating = 2 + chance_of_fire = True + elif tt < 10: + if resp.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=16) + await ctx.send(f"Great! You made {ltr_a} delicious **{na}** in {round(tt)} seconds! You've earned **{c}** EXP.") + rating = 5 + else: + if retry_allowed and 'opportunity' in post['stones']: + await ctx.send(f"You failed to unscramble the letter, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! One more chance, what is `{sw}`?") + resp2 = await self.bot.wait_for('message', check=nc, timeout=120) + if resp2.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=7) + await ctx.send(f"I knew you could do it! You received **{c} EXP** for making {ltr_a} **{na}**.") + else: + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed again to unscramble the letters. You've earned **{c}** EXP for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + return + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned **0 EXP** for making {ltr_a} disgusting {na}.") + rating = 1 + chance_of_fire = True + elif tt < 12: + if resp.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=14) + await ctx.send(f"Nice! You made {ltr_a} good **{na}** in {round(tt)} seconds! You've earned **{c} EXP**.") + rating = 4 + else: + if retry_allowed and 'opportunity' in post['stones']: + await ctx.send(f"You failed to unscramble the letter, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! One more chance, what is `{sw}`?") + resp2 = await self.bot.wait_for('message', check=nc, timeout=120) + if resp2.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=7) + await ctx.send(f"I knew you could do it! You received **{c} EXP** for making {ltr_a} **{na}**.") + else: + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed again to unscramble the letters. You've earned **{c}** EXP for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + return + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned **0 EXP** for making {ltr_a} disgusting **{na}**.") + rating = 1 + chance_of_fire = True + elif tt < 14: + if resp.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=8) + await ctx.send(f"OK! You made {ltr_a} not-too-bad **{na}** in {round(tt)} seconds! You've earned **{c} EXP**.") + rating = 4 + else: + if retry_allowed and 'opportunity' in post['stones']: + await ctx.send(f"You failed to unscramble the letter, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! One more chance, what is `{sw}`?") + resp2 = await self.bot.wait_for('message', check=nc, timeout=120) + if resp2.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=7) + await ctx.send(f"I knew you could do it! You received **{c} EXP** for making {ltr_a} **{na}**.") + else: + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed again to unscramble the letters. You've earned **{c}** EXP for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + return + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned **0 EXP** for making {ltr_a} disgusting {na}.") + rating = 1 + chance_of_fire = True + elif tt < 18: + if resp.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=6) + await ctx.send(f"Eh! You made {ltr_a} decent **{na}** in {round(tt)} seconds! You've earned **{c} EXP**.") + rating = 3 + else: + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned 0 EXP for making {ltr_a} disgusting {na}.") + rating = 1 + chance_of_fire = True + else: + chance_of_fire = True + if resp.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=1) + await ctx.send(f"Uh oh! You made {ltr_a} disgusting **{na}** in {round(tt)} seconds! You've earned **{c} EXP**.") + rating = 3 + else: + if retry_allowed and 'opportunity' in post['stones']: + await ctx.send(f"You failed to unscramble the letter, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! One more chance, what is `{sw}`?") + resp2 = await self.bot.wait_for('message', check=nc, timeout=120) + if resp2.content.lower() == word.lower(): + c = await self.add_exp(user=ctx.author.id, count=7) + await ctx.send(f"I knew you could do it! You received **{c} EXP** for making {ltr_a} **{na}**.") + else: + c = await self.add_exp(user=ctx.author.id, count=2) + await ctx.send(f"Uh oh! You failed again to unscramble the letters. You've earned **{c}** EXP for making {ltr_a} bad **{na}**.") + rating = 3 + chance_of_fire = True + return + await ctx.send(f"Uh oh! You failed to unscramble the letters. You've earned **0 EXP** for making {ltr_a} disgusting **{na}**.") + rating = 1 + if chance_of_fire: + if not "fire" in post['bonuses']: + if fire_chance == 1: + embed = discord.Embed(color=0xff1f1f, description=f":fire: **FIRE!** :fire:\n\nYou burnt the {na} so bad that it caused a kitchen fire! You will receive -40% EXP on all commands until you use a fire extinguisher!\n\nTo buy an extinguisher, do `b.buy item`") + db.market.update_one({"owner": ctx.author.id}, {"$push": {"bonuses": "fire"}}) + await ctx.send(embed=embed) + + else: + chance_of_fire = False + bar_int = 0 + country = post['country'] + flist = None + for c in food.can_burn: + if country in c: + flist = c + cfood = rnd(flist[country]) + if cfood.endswith("s"): + cfooda = "the " + cfood else: + if cfood.startswith(("a", "e", "i", "o", "u")): + cfooda = "an " + cfood + else: + cfooda = "a " + cfood + + done = False + desc = f"Click `stop` when the bar gets to red. Don't burn it!\n\n`🟨`" + embed = discord.Embed(description=desc) + embed.set_footer(text=f"You're cooking {cfooda}.") + + button = Button(label="Stop", style=discord.ButtonStyle.red) + view = View() + view.add_item(button) + + async def button_callback(interaction): + nonlocal done, bar_int, bar + if interaction.user == ctx.author: + await interaction.response.defer() + done = True + if bar_int > 5: + embed.set_footer(text=None) + embed.description = f"You burnt **{cfooda}**! No EXP for you...\n\n{bar}" + embed.color = 0x000000 + chance_of_fire = True + rating = 1 + elif bar_int == 5: + embed.set_footer(text=None) + exp_r = await self.add_exp(user=ctx.author.id, count=23) + embed.description = f"You cooked **{cfooda}** perfectly! You received {exp_r} EXP!\n\n{bar}" + rating = 5 + elif bar_int == 4: + embed.set_footer(text=None) + exp_r = await self.add_exp(user=ctx.author.id, count=15) + embed.description = f"You almost cooked **{cfooda}** perfectly. You received {exp_r} for the effort!\n\n{bar}" + rating = 4 + else: + embed.set_footer(text=None) + exp_r = await self.add_exp(user=ctx.author.id, count=5) + embed.description = f"You undercooked **{cfooda}**! You received {exp_r} EXP for the effort!\n\n{bar}" + rating = 3 + await interaction.edit_original_response(embed=embed, view=None) + + button.callback = button_callback + await asyncio.sleep(1) + msg = await ctx.send(embed=embed, view=view) + while bar_int <= 6 and not done: bar_int += 1 - bar = str(bar_int).replace("7", "`🟨🟨🟧🟥🟥⬛`").replace("6", "`🟨🟨🟧🟥🟥⬛`").replace("5", "`🟨🟨🟧🟥🟥`").replace("4", "`🟨🟨🟧🟥`").replace("3", "`🟨🟨🟧`").replace("2", "`🟨🟨`") - embed = discord.Embed(colour=0xa82021, description=f"Say `stop` when the bar gets to red. Don't let it get burnt!\n\n{bar}") + bar = str(bar_int).replace("7", "`🟨🟨🟧🟧🟥⬛`").replace("6", "`🟨🟨🟧🟧🟥⬛`").replace("5", "`🟨🟨🟧🟧🟥`").replace("4", "`🟨🟨🟧🟧`").replace("3", "`🟨🟨🟧`").replace("2", "`🟨🟨`").replace("1", "`🟨`") + embed = discord.Embed(description=f"Click `stop` when the bar gets to red. Don't burn it!\n\n{bar}") if bar_int == 7: - embed.set_footer(text=f"You burnt the {cfood}!") + embed.set_footer(text=None) + embed.description = f"You burnt **{cfooda}**! No EXP for you...\n\n{bar}" + rating = 1 + chance_of_fire = True + embed.color = 0x000000 done = True - elif bar_int > 6: + elif bar_int > 5: + embed.color = 0x000000 embed.set_footer(text=f"You're burning the {cfood}!") + elif bar_int == 5: + embed.color = 0xfc2121 + elif bar_int == 3 or bar_int == 4: + embed.color = 0xfa8c16 else: + embed.color = 0xf9ff40 embed.set_footer(text=f"You're cooking {cfooda}.") + await msg.edit(embed=embed) - await asyncio.sleep(0.8) - if resp.content == 'stop': - done = True - await ctx.send('worked') - - #async def text(): - #loop = asyncio.get_event_loop() - #wfm = loop.create_task(self.bot.wait_for('message', check=nc, timeout=90)) - #inc = loop.create_task(increase()) - #loop.run_until_complete(wfm) - #wfm = asyncio.run_coroutine_threadsafe(wfm) - #inc = asyncio.run_coroutine_threadsafe(inc) - #wfm.result() - #done = True - #await ctx.send(wfm) - #inc.result() - #loop.run_until_complete(inc) - #loop = asyncio.get_event_loop() - #loop.run_until_complete(text()) - #resp = loop.run_until_complete(self.bot.wait_for('message', check=nc, timeout=240)) - else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") + await asyncio.sleep(0.6) + if not done: + + embed.set_footer(text=None) + embed.description = f"You burnt **{cfooda}**! No EXP for you...\n\n{bar}" + embed.color = 0x000000 + rating = 1 + chance_of_fire = True + done = True - @commands.command(aliases=['Cook', 'Bake', 'bake']) - @commands.cooldown(1, 150, commands.BucketType.user) - async def cook(self, ctx): - def nc(m): - return m.author == ctx.author and m.channel == ctx.channel and not m.content.startswith("r!menu") - post = db.market.find_one({"owner": ctx.author.id}) - #words = ['potato', 'bun', 'bread', 'cheese', 'tomato', 'olive', 'fish', 'seafood', 'chicken', 'lettuce', 'rice', 'ham', 'turkey', 'soup', 'meat', 'fruit', 'noodles', 'pie', 'water', 'milk', 'cake', 'juice', 'cookie', 'pepper'] - #to_cook = [{'adj': 'a tasty', 'exp': 10}, {'adj': 'a disgusting', 'exp': 0}, {'adj': 'a delicious', 'exp': 15}, {'adj': 'a burnt', 'exp': 1}, {'adj': 'an okay', 'exp': 3}, {'adj': 'a great', 'exp': 6}, {'adj': 'a great', 'exp': 9}, {'adj': 'a not-too-bad', 'exp': 4}] - if post: - word = rnd(post['items'])['name'] - ws = word.split(" ") - new = [] - for x in ws: - li = list(x) - random.shuffle(li) - sw = "".join(li) - new.append(sw) - sw = " ".join(new) - na = word - await ctx.send(f'{ctx.author.mention}, Unscramble this item on your menu to make it: `{sw}`') - b = time.perf_counter() - resp = await self.bot.wait_for('message', check=nc, timeout=240) - a = time.perf_counter() - tt = a-b - if tt < 6: - if resp.content.lower().lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=20) - await ctx.send(f"Perfect! You made a delicious {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - c = await self.add_exp(user=ctx.author.id, count=2) - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned {c} EXP for making a bad {na}.") - elif tt < 8: - if resp.content.lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=16) - await ctx.send(f"Amazing! You made a tasty {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - c =await self.add_exp(user=ctx.author.id, count=1) - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned {c} EXP for making a terrible {na}.") - elif tt < 10: - if resp.content.lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=12) - await ctx.send(f"Great! You made a delicious {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned 0 EXP for making a disgusting {na}.") - elif tt < 12: - if resp.content.lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=10) - await ctx.send(f"Nice! You made a good {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned 0 EXP for making a disgusting {na}.") - elif tt < 14: - if resp.content.lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=8) - await ctx.send(f"OK! You made a not-too-bad {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned 0 EXP for making a disgusting {na}.") - elif tt < 18: - if resp.content.lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=6) - await ctx.send(f"Eh! You made an okay {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned 0 EXP for making a disgusting {na}.") - else: - if resp.content.lower() == word.lower(): - c = await self.add_exp(user=ctx.author.id, count=1) - await ctx.send(f"Uh oh! You made a disgusting {na} in {round(tt)} seconds! You've earned {c} EXP.") - else: - await ctx.send(f"Uh oh! You failed to unscramble the letter. You've earned 0 EXP for making a disgusting {na}.") + await msg.edit(view=None) + if chance_of_fire: + if not "fire" in post['bonuses']: + if fire_chance == 1: + embed = discord.Embed(color=0xff1f1f, description=f":fire: **FIRE!** :fire:\n\nYou burnt the {cfood} so bad that it caused a kitchen fire! You will receive -40% EXP on all commands until you use a fire extinguisher!\n\nTo buy an extinguisher, do `b.buy item`") + db.market.update_one({"owner": ctx.author.id}, {"$push": {"bonuses": "fire"}}) + await ctx.send(embed=embed) + await self.add_rating(user=ctx.author.id, rating=rating) else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`.") + @commands.command(aliases=['Restaurant', 'r']) @commands.cooldown(1, 3, commands.BucketType.user) async def restaurant(self, ctx, *, restaurant=None): + await ctx.typing() post = None if not restaurant: - post = db.market.find_one({"owner":ctx.author.id}) + post = await db.market.find_one({"owner":ctx.author.id}) elif ctx.message.mentions: if len(ctx.message.mentions) >= 2: - post = db.market.find_one({"owner":ctx.message.mentions[1].id}) + post = await db.market.find_one({"owner":ctx.message.mentions[1].id}) else: - post = db.market.find_one({"owner":ctx.message.mentions[0].id}) + post = await db.market.find_one({"owner":ctx.message.mentions[0].id}) else: - post = db.market.find_one({"name":restaurant}) + post = await db.market.find_one({"name":restaurant}) if not post: await ctx.send('<:RedTick:653464977788895252> I couldn\'t find that restaurant in our database.') else: + stones_ta = [] + for x in post['stones']: + if x == 'agility': + stones_ta.append("<:AgilityStone:1331501018768347157>") + elif x == 'opportunity': + stones_ta.append("<:OpportunityStone:1331504493015076914>") + elif x == 'endearing': + stones_ta.append("<:EndearingStone:1331822694202871851>") + elif x == 'ambience': + stones_ta.append("<:AmbienceStone:1331825641703604225>") + event = await db.events.find_one({"user_id": post['owner']}) def react(reaction, user): return str(reaction.emoji) == '<:FilledStar:651156130424291368>' prices = [] @@ -1117,7 +1942,7 @@ def react(reaction, user): stars = "<:FilledStar:651156130424291368><:FilledStar:651156130424291368><:FilledStar:651156130424291368><:FilledStar:651156130424291368><:FilledStar:651156130424291368>" country = str(post['country']).lower() ldi = post['items'] - patrons = db.utility.find_one({"utility": "patrons"}) + patrons = await db.utility.find_one({"utility": "patrons"}) if post['owner'] in patrons['bronze']: badge = " <:BronzeBadge:667504528006053947>" elif post['owner'] in patrons['silver']: @@ -1129,92 +1954,188 @@ def react(reaction, user): else: badge = "" list = sorted(ldi, key=lambda x: x['sold'], reverse=True) - embed = discord.Embed(description=post['description']) - level = str(post['level']) + fire_msg = "" + if 'fire' in post['bonuses']: + fire_msg = ":fire: **ON FIRE** :fire:\n" + embed = discord.Embed(description=fire_msg+f"{" ".join(stones_ta)}\n{post['description']}\n\u200b") + level = int(post['level']) owner = post['owner'] - + perday = await self.calc_customers(owner) + emoji = self.levelEmoji[str(level)] + embed.set_author(icon_url=self.flags[country], name=post['name']) #+ f" {self.levelEmoji[level]}") - embed.add_field(name=":notepad_spiral: Menu", value=post['items'][0]['name'] + ", " + post['items'][1]['name'] + ", " + post['items'][2]['name'] + f"... To view the full menu, do `r!menu {post['name']}`") - embed.add_field(name=":bar_chart: Experience", value=format(post['exp'], ",d")) - embed.add_field(name=":moneybag: Average Price", value="$" + str(average)) - embed.add_field(name=":page_with_curl: Rating", value=stars) + #embed.add_field(name="Menu", value=post['items'][0]['name'] + ", " + post['items'][1]['name'] + ", " + post['items'][2]['name'] + f"... View the full menu with `b.menu {post['name']}`") + embed.add_field(name="Rating", value=stars) + if post['special']: + embed.add_field(name="Specialty", value=post['special']) + embed.add_field(name="Average Price", value="<:BistroBux:1324936072760786964>" + str(average)) + embed.add_field(name="Experience", value=format(post['exp'], ",d") + f" ({emoji})") + embed.add_field(name="Customers", value=f"{post['customers']} ({perday}/day)") + if post['awards']: + award_emoji = [] + for award in post['awards']: + award_emoji.append(awards.awards[award]['emoji']) + embed.add_field(name="Awards", value=" ".join(award_emoji)) + if event: + if event['type'] == 'tn': + e_desc = ":question: Trivia Night" + elif event['type'] == 'kn': + e_desc = ":notes: Karaoke Night" + elif event['type'] == 'ayce': + e_desc = ":meat_on_bone: All-You-Can-Eat" + embed.add_field(name="ONGOING EVENT!", value=e_desc) + #await ctx.send(f"id > {post['owner']}") - embed.add_field(name=":name_badge: Owner", value=str(self.bot.get_user(owner)).replace("None", "Unknown") + badge) + embed.add_field(name="Owner", value=str(self.bot.get_user(owner)).replace("None", "Unknown") + badge) try: if post['banner']: embed.set_image(url=post['banner']) else: pass if post['colour']: - #postc = int(post['colour']) - #colour = postc.replace(16777215, 12763842) - #print(colour) - embed.colour = post['colour'] + if post['colour'] == 0x171717: + embed.colour = random.randint(0, 0xFFFFFF) + else: + embed.colour = post['colour'] else: pass except: pass if not post['logo_url']: - embed.set_thumbnail(url=ctx.me.avatar_url_as(format='png')) + embed.set_thumbnail(url=ctx.bot.user.avatar.url) else: embed.set_thumbnail(url=post['logo_url']) embed.set_footer(text=f"Level {level} | Last Work: {post['laststock']}") - msg = await ctx.send(embed=embed) + view = self.ButtonView(self.bot, user_id=post['owner'], cog=self) + msg = await ctx.send(embed=embed, view=view) @commands.command(aliases=['Level']) @commands.cooldown(1,3, commands.BucketType.user) async def level(self, ctx): - user = db.market.find_one({"owner": ctx.author.id}) + user = await db.market.find_one({"owner": ctx.author.id}) nextLevel = str(user['level']+1) - if user['level'] != 6: + if user['level'] != 15: cl = f"will level up to Level {nextLevel} next" a = True else: cl = f"cannot level up further" a = False - embed = discord.Embed(colour=0xa82021, description=f"You are currently Level {user['level']}, which means you {cl}.\n\nRestaurant Levels are bought with EXP. The more you level up, the more the next level will cost. You get money and cool perks for levelling up! To level up, do `r!levelup`.") - embed.set_author(name="Restaurant Levelling", icon_url=ctx.me.avatar_url_as(format="png")) + embed = discord.Embed(colour=0x8980d9, description=f"{self.levelEmoji[str(user['level'])]} You are currently Level {user['level']}, which means you {cl}.\n\nBistro Levels are bought with EXP. The more you level up, the more the next level will cost. You get money and cool perks for leveling up! To level up, do `b.levelup`. Or if you want to see all the unlockables, do `b.levelunlocks`") + embed.set_author(name="Bistro Leveling", icon_url=ctx.me.avatar.with_format('png')) if a: embed.set_footer(text=f"You need {self.exp_needed[nextLevel]} EXP to level up to {nextLevel}!") await ctx.send(embed=embed) + @commands.command(aliases=['Levelunlocks', 'lvlunlocks']) + @commands.cooldown(1,3, commands.BucketType.user) + async def levelunlocks(self, ctx): + description = "All Level Unlockables\n\n" + for key, val in self.unlocks.items(): + emoji = self.levelEmoji[str(key)] + exp = self.exp_needed[key] + description += f"{emoji} **Level {key}** `{exp} EXP req.`\n{", ".join(val)}\n" + embed = discord.Embed(colour=0x8980d9, description=description) + await ctx.send(embed=embed) + @commands.command(aliases=["Levelup", "LevelUp"]) @commands.cooldown(1, 3, commands.BucketType.user) async def levelup(self, ctx): - user = db.market.find_one({"owner": ctx.author.id}) + user = await db.market.find_one({"owner": ctx.author.id}) nextLevel = user['level']+1 if not user: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `r!restaurant`.") - elif user['level'] >= 6: - await ctx.send("<:RedTick:653464977788895252> You are currently level 6 (max level) and cannot level further!") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.start`.") + elif user['level'] >= 15: + await ctx.send("<:RedTick:653464977788895252> You are currently level 15 (max level) and cannot level further.") elif user['exp'] < self.exp_needed[str(nextLevel)]: - await ctx.send("<:RedTick:653464977788895252> You do not have enough EXP to perform this action!") + await ctx.send("<:RedTick:653464977788895252> You do not have enough EXP to perform this action! See your progression with `b.level`.") else: - await self.take_exp(ctx.author.id, self.exp_needed[str(nextLevel)]) - if nextLevel <= 4: + await self.take_exp(ctx.author.id, self.exp_needed[str(nextLevel)]) + if nextLevel == 2: + money = 100 + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "ep"}}}) + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"luck": 1}}) + elif nextLevel == 3: + money = 100 + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"luck": 1}}) + elif nextLevel == 5: + money = 300 + elif nextLevel == 6: + money = 100 + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"luck": 1}}) + elif nextLevel == 7: + money = 500 + elif nextLevel == 8: + money = 100 + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"luck": 1}}) + elif nextLevel == 9: + money = 100 + frag = await self.add_rand_fragment(ctx.author.id, all=True) + elif nextLevel == 10: money = 500 + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"apron_uses": 20}}) + elif nextLevel == 12: + money = 100 + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "tm"}}}) + elif nextLevel == 13: + money = 100 + await db.market.update_one({"owner": ctx.author.id}, {"$inc": {"luck": 1}}) + elif nextLevel == 15: + money = 500 + await db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"item": "tm"}}}) else: - money = 250 + money = 100 + await self.add_money(ctx.author.id, money) - db.market.update_one({"owner": ctx.author.id}, {"$set":{"level": nextLevel}}) + await ctx.typing() await asyncio.sleep(0.3) cl = user['level'] - unlocks = "• " + "\n- ".join(self.unlocks[str(nextLevel)]) - nextUnlocks = "• " + "\n- ".join(self.unlocks[str(nextLevel+1)]) - embed = discord.Embed(colour=0xa82021, description=f"{self.levelEmoji[str(nextLevel)]} **Level up!** You've unlocked...\n{unlocks}") + unlocks = "\n* " + "\n* ".join(self.unlocks[str(nextLevel)]) + nextUnlocks = "* " + "\n* ".join(self.unlocks[str(nextLevel+1)]) + embed = discord.Embed(colour=0x8980d9, description=f"{self.levelEmoji[str(nextLevel)]} **Level up!** You've unlocked...\n{unlocks}") embed.add_field(name="Next Unlocks...", value=nextUnlocks) - embed.set_footer(text=f"You've also earned ${money} for levelling up!") + #embed.set_footer(text=f"You've also earned {money} BB for leveling up!") await ctx.send(embed=embed) + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"level": nextLevel}}) + if "levelup" in user['tasks']: + ix = user['tasks'].index("levelup") + if user['task_list'][ix]['completed']+1 == 1: + await ctx.author.send(f"You have completed the **{user['task_list'][ix]['description']}** task. You have been awarded **{user['task_list'][ix]['rewards']} EXP**.") + await self.add_exp(user=ctx.author.id, count=user['task_list'][ix]['rewards'], multiplier=False) + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "levelup"},{"$set": {"task_list.$.completed": 1}}) @commands.command(aliases=['Start', 'create']) @commands.cooldown(1, 3, commands.BucketType.user) async def start(self, ctx): - user = db.market.find_one({"owner": ctx.author.id}) + user = await db.market.find_one({"owner": ctx.author.id}) if not user: def check(m): return m.author == ctx.message.author - embed = discord.Embed(colour=0xa82021, description='Welcome to Restaurant! First off, which country do you want your theme as? Pick one from this list:\n'\ + + cancel_event = asyncio.Event() + to_delete = None + + class CancelView(View): + def __init__(self): + super().__init__() + + @discord.ui.button(label="X", style=discord.ButtonStyle.danger) + async def cancel_button(self, interaction: discord.Interaction, button: Button): + if interaction.user == ctx.author and not button.disabled: + button.disabled = True + await interaction.response.send_message("Creation process canceled.", ephemeral=True) + cancel_event.set() + if to_delete: + await to_delete.delete() + + view = CancelView() + + embed = discord.Embed(colour=0x8980d9, description='Welcome to **Bistro**! First off, which **theme** would you like? Pick one from this list:\n\n'\ + ':cupcake: Bakery\n'\ + ':beers: Bar\n'\ + ':coffee: Cafe\n'\ + ':pizza: Pizzeria\n\n'\ + ':flag_br: Brazil\n'\ ':flag_cn: China\n'\ ':flag_fr: France\n'\ ':flag_gr: Greece\n'\ @@ -1223,141 +2144,321 @@ def check(m): ':flag_jp: Japan\n'\ ':flag_mx: Mexico\n'\ ':flag_ru: Russia\n'\ + ':flag_sg: Singapore\n'\ + ':flag_kr: South Korea\n'\ ':flag_tr: Turkey\n'\ ':flag_gb: United Kingdom\n'\ ':flag_us: United States\n' ) - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Restaurant Creation") - embed.set_footer(text="You have 90 seconds to reply | You cannot change your theme later on!") - msg1 = await ctx.send(embed=embed) + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Restaurant Creation") + embed.set_footer(text="You have 90 seconds to reply | You CANNOT change your theme later on!") + msg1 = await ctx.send(embed=embed, view=view) country = await self.bot.wait_for('message', check=check, timeout=90) + if cancel_event.is_set(): + to_delete = msg1 + return try: await country.delete() except: pass if not country.content.upper() in self.countries: - failed = discord.Embed(colour=0xa82021, description="That is not in the list of countries.") - failed.set_author(name="Creation Failed.") - await msg1.edit(embed=failed) + failed = discord.Embed(colour=0xff0000, description="That is not in the list of countries.") + failed.set_author(name="Creation Failed. Please try the command again.") + await msg1.edit(embed=failed, view=None) else: - embed = discord.Embed(colour=0xa82021, description='Great! What would you like to name your restaurant? It must be 36 characters or less. You can change this later on!') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Restaurant Creation") + embed = discord.Embed(colour=0x8980d9, description='Great! What would you like to **name** your restaurant? It must be 36 characters or less. You can change this later on!') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Restaurant Creation") embed.set_footer(text="You have 90 seconds to reply") - await msg1.edit(embed=embed) + ms1 = await msg1.edit(embed=embed, view=view) name = await self.bot.wait_for('message', check=check, timeout=90) + if cancel_event.is_set(): + to_delete = ms1 + return try: await name.delete() except: pass if len(str(name.content)) > 36: - failed = discord.Embed(colour=0xa82021, description="Restaurant name must be 36 characters or less") - failed.set_author(name="Creation Failed.") - msg1.edit(embed=failed) + failed = discord.Embed(colour=0xff0000, description="Restaurant name must be 36 characters or less") + failed.set_author(name="Creation Failed. Please try the command again.") + msg1.edit(embed=failed, view=None) else: - embed = discord.Embed(colour=0xa82021, description='Almost done! What would you like as your description? It must be 130 characters or less. You can change this later on!') - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Restaurant Creation") + embed = discord.Embed(colour=0x8980d9, description='Almost done! What would you like as your **description**? It must be 130 characters or less. You can change this later on!') + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Restaurant Creation") embed.set_footer(text="You have 90 seconds to reply") - await msg1.edit(embed=embed) + ms2 = await msg1.edit(embed=embed, view=view) desc = await self.bot.wait_for('message', check=check, timeout=90) + if cancel_event.is_set(): + to_delete = ms2 + return try: await desc.delete() except: pass if len(str(desc.content)) > 130: - failed = discord.Embed(colour=0xa82021, description="Restaurant description must be 130 characters or less") - failed.set_author(name="Creation Failed.") - await msg1.edit(embed=failed) + failed = discord.Embed(colour=0xff0000, description="Restaurant description must be 130 characters or less") + failed.set_author(name="Creation Failed. Please try the command again.") + await msg1.edit(embed=failed, view=None) else: new_name = str(name.content).replace('nigg','n*gg').replace('Nigg','N*gg').replace('NIGG','N*GG').replace('fag', 'f*g').replace('FAG', 'f*g').replace("Fag", "F*g") await self.update_data(ctx.author, country.content.lower(), new_name, desc.content) - embed = discord.Embed(colour=0xa82021, description=f'And... Done! Your Restaurant has been created. \n\nCheck your restaurant out with `{self.prefix}restaurant` and view all Restaurant commands with `r!help`.') + embed = discord.Embed(colour=0x8980d9, description=f'And... Done! Your Restaurant has been created. \n\nCheck your restaurant out with `{self.prefix}restaurant` and view all Restaurant commands with `b.help`.') embed.add_field(name="Quick Tips", value=":one: [Earn some money](http://paixlukee.dev/m/PL0LD.mp4)\n:two: [Set a custom logo](https://paixlukee.dev/m/CBXXZ.mp4)\n:three: [Hire a worker](https://paixlukee.dev/m/1GZCD.mp4)\n:four: [Buy a custom item and use it](https://paixlukee.dev/m/DEMD4.mp4)\n:five: [Level up your Restaurant](https://docs.google.com/document/d/1sTv9vN3TucTGx8rmRHw6FDfTvJ_TWJN7vVitqrqDLP0/edit?usp=sharing)") - embed.set_author(icon_url=ctx.me.avatar_url_as(format='png'), name="Restaurant Creation") + embed.set_author(icon_url=ctx.bot.user.avatar.url, name="Restaurant Creation") await msg1.edit(embed=embed) else: - await ctx.send(f'<:RedTick:653464977788895252> You already have a restaurant created. View it with `r!restaurant`.') + await ctx.send(f'<:RedTick:653464977788895252> You already have a restaurant created. View it with `b.restaurant`.') @commands.command(aliases=['Tasks', 'challenges', 'quests']) @commands.cooldown(1, 3, commands.BucketType.user) async def tasks(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) + if not post: + await ctx.send("<:RedTick:653464977788895252> You do not have a restaurant! Start one with `b.start`") + return if not 'tasks' in post or post['tasks'] == []: - await ctx.send("Setting your challenges...") - t1 = random.choice(quests.questlist1)[0] - t2 = random.choice(quests.questlist2)[0] + ms = await ctx.send("Setting your challenges. Please wait...") + await ctx.typing() + t1 = random.choice(quests.questlist1) + t2 = random.choice(quests.questlist2) t3 = random.choice(quests.questlist3) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"task_list": [t1, t2, t3]}}) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"tasks": [t1['name'], t2['name'], t3['name']]}}) - await asyncio.sleep(1) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"task_list": [t1, t2, t3]}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"tasks": [t1['name'], t2['name'], t3['name']]}}) + await asyncio.sleep(2) + await ms.delete() + post = await db.market.find_one({"owner": ctx.author.id}) task1 = post['task_list'][0] task2 = post['task_list'][1] task3 = post['task_list'][2] - progress = task1['completed']/task1['total'] - if progress == 1: + progress_1 = task1['completed']/task1['total'] + if progress_1 >= 1: bar1 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764>' - elif progress >= 0.8: + elif progress_1 >= 0.8: bar1 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:blacksq:829872214899556392>' - elif progress >= 0.6: + elif progress_1 >= 0.6: bar1 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:blacksq:829872214899556392><:blacksq:829872214899556392>' - elif progress >= 0.4: + elif progress_1 >= 0.4: bar1 = '<:greensq:829870925583089764><:greensq:829870925583089764><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' - elif progress >= 0.2: + elif progress_1 >= 0.2: bar1 = '<:greensq:829870925583089764><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' else: bar1 = '<:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' - progress = task2['completed']/1 - if progress == 1: + progress_2 = task2['completed']/1 + if progress_2 == 1: bar2 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764>' else: bar2 = '<:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' - progress = task3['completed']/task3['total'] - if progress == 1: + progress_3 = task3['completed']/task3['total'] + if progress_3 >= 1: bar3 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764>' - elif progress >= 0.8: + elif progress_3 >= 0.8: bar3 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:blacksq:829872214899556392>' - elif progress >= 0.6: + elif progress_3 >= 0.6: bar3 = '<:greensq:829870925583089764><:greensq:829870925583089764><:greensq:829870925583089764><:blacksq:829872214899556392><:blacksq:829872214899556392>' - elif progress >= 0.4: + elif progress_3 >= 0.4: bar3 = '<:greensq:829870925583089764><:greensq:829870925583089764><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' - elif progress >= 0.2: + elif progress_3 >= 0.2: bar3 = '<:greensq:829870925583089764><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' else: bar3 = '<:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392><:blacksq:829872214899556392>' - embed=discord.Embed(colour=0xa82021, description=f"**{task1['description']}**\n{bar1} *({task1['completed']}/{task1['total']})* `{task1['rewards']} EXP`"\ - f"\n**{task2['description']}**\n{bar2} *({task2['completed']}/1)* `${task2['rewards']}`"\ - f"\n**{task3['description']}**\n{bar3} *({task3['completed']})/{task3['total']}* `${task3['rewards']}`") - embed.set_author(name="Weekly Tasks", icon_url=ctx.author.avatar_url_as(format="png")) + + if task1['completed'] >= task1['total']: + task1_comp = 'Completed' + else: + task1_comp = f"{task1['completed']}/{task1['total']}" + if task2['completed'] == 1: + task2_comp = 'Completed' + else: + task2_comp = "0/1" + if task3['completed'] >= task3['total']: + task3_comp = "Completed" + else: + task3_comp = f"{task3['completed']}/{task3['total']}" + embed=discord.Embed(colour=0x8980d9, description=f"**{task1['description']}**\n{bar1} *({task1_comp})* `{task1['rewards']} EXP`"\ + f"\n**{task2['description']}**\n{bar2} *({task2_comp})* <:BistroBux:1324936072760786964>`{task2['rewards']}`"\ + f"\n**{task3['description']}**\n{bar3} *({task3_comp})* <:BistroBux:1324936072760786964>`{task3['rewards']}`") + embed.set_author(name="Weekly Tasks", icon_url=ctx.author.avatar.url) embed.set_footer(text="Tasks reset weekly.") await ctx.send(embed=embed) + + async def dynamic_cd(self, user, cmd, cd_time): + result = await db.cooldowns.find_one({"user_id": user, "command_name": cmd}) + if result: + expires_at = result["expires_at"] + if dttm.utcnow() < expires_at: + remaining_time = (expires_at - dttm.utcnow()).total_seconds() + return True, remaining_time + expires_at = dttm.utcnow() + timedelta(seconds=cd_time) + await db.cooldowns.update_one( + {"user_id": user, "command_name": cmd}, + {"$set": {"expires_at": expires_at}}, + upsert=True + ) + return False, None + + + async def get_image_dimensions(self, url:str): + try: + response = requests.get(url, stream=True) + response.raise_for_status() + img = Image.open(response.raw) + width, height = img.size + ar = width / height + return ar + except: + return 0 + + async def get_award(self, user, award): + post = await db.market.find_one({"owner": user}) + has_award = False + added = False + for x in post['awards']: + if x == award: + has_award = True + if not has_award: + await db.market.update_one({"owner": user}, {"$push": {"awards": award}}) + added = True + return added - async def add_money(self, user:int, count): - data = db.market.find_one({"owner": user}) + async def luck_up(self, user:int): + data = await db.market.find_one({"owner": user}) + new_lvl = data['luck'] + 1 + await db.market.update_one({"owner": user}, {"$set":{"luck": new_lvl}}) + + + async def add_money(self, user:int, count, check_tasks=False): + data = await db.market.find_one({"owner": user}) bal = data['money'] money = int(bal) + count - db.market.update_one({"owner": user}, {"$set":{"money": money}}) + await db.market.update_one({"owner": user}, {"$set":{"money": money}}) + if data['money'] >= 500 and not 'fivehundred_bbux' in data['awards']: + award = await self.get_award(user, "fivehundred_bbux") + elif data['money'] >= 1500 and not 'thousand_bbux' in data['awards']: + award = await self.get_award(user, "thousand_bbux") + elif data['money'] >= 3000 and not 'twothousand_bbux' in data['awards']: + award = await self.get_award(user, "twothousand_bbux") + if check_tasks: + if "earn_money" in data['tasks']: + ix = data['tasks'].index("earn_money") + if data['task_list'][ix]['completed']+count >= data['task_list'][ix]['total']: + await ctx.author.send(f"You have completed the **{data['task_list'][ix]['description']}** task. You have been awarded {bbux}**{data['task_list'][ix]['rewards']}**.") + await db.market.update_one({"owner": user}, {"$inc":{"money": data['task_list'][ix]['rewards']}}) + await db.market.update_one({"owner": user}, {"$pull":{"tasks": "earn_money"}}) + await db.market.update_one({"owner": user, "task_list.name": "earn_money"},{"$inc": {"task_list.$.completed": count}}) + else: + await db.market.update_one({"owner": user, "task_list.name": "earn_money"},{"$inc": {"task_list.$.completed": count}}) async def take_money(self, user:int, count:int): - data = db.market.find_one({"owner": user}) + data = await db.market.find_one({"owner": user}) bal = data['money'] money = int(bal) - count - db.market.update_one({"owner": user}, {"$set":{"money": money}}) + await db.market.update_one({"owner": user}, {"$set":{"money": money}}) - async def add_exp(self, user, count): - data = db.market.find_one({"owner": user}) + async def add_exp(self, user, count, check_tasks=False): + data = await db.market.find_one({"owner": user}) bal = data['exp'] if 'worker' in data: if data['worker']: wn = data['worker_name'] count = count + round(count*data['worker'][wn][0]['exp']) + if 'fire' in data['bonuses']: + count = count - round(count*0.4) exp = int(bal) + count - db.market.update_one({"owner": user}, {"$set":{"exp": exp}}) + await db.market.update_one({"owner": user}, {"$set":{"exp": exp}}) + await db.market.update_one({"owner": user}, {"$inc":{"total_exp": count}}) return count + if check_tasks: + if "earn_exp" in data['tasks']: + ix = data['tasks'].index("earn_exp") + if data['task_list'][ix]['completed']+count >= data['task_list'][ix]['total']: + await ctx.author.send(f"You have completed the **{data['task_list'][ix]['description']}** task. You have been awarded {bbux}**{data['task_list'][ix]['rewards']}**.") + await db.market.update_one({"owner": user}, {"$inc":{"money": data['task_list'][ix]['rewards']}}) + await db.market.update_one({"owner": user}, {"$pull":{"tasks": "earn_exp"}}) + await db.market.update_one({"owner": user, "task_list.name": "earn_exp"},{"$inc": {"task_list.$.completed": count}}) + else: + await db.market.update_one({"owner": user, "task_list.name": "earn_exp"},{"$inc": {"task_list.$.completed": count}}) async def take_exp(self, user, count): - data = db.market.find_one({"owner": user}) + data = await db.market.find_one({"owner": user}) bal = data['exp'] exp = int(bal) - count - db.market.update_one({"owner": user}, {"$set":{"exp": exp}}) + await db.market.update_one({"owner": user}, {"$set":{"exp": exp}}) + return count + + async def add_rating(self, user, rating): + post = await db.market.find_one({"owner": user}) + if 'endearing' in post['stones']: + if rating < 5: + rating += 1 + await db.market.update_one({"owner": user}, {"$push":{"ratings": {"rating": rating, "user": 1}}}) + + async def add_rand_fragment(self, user, all=False): + post = await db.market.find_one({"owner": user}) + fragments = ['agility', 'opportunity', 'endearing', 'ambience'] + exclude = post['stones'] + if all: + for fragment in fragments: + if fragment in exclude: + continue + in_list = False + for frag in post['fragments']: + if frag['stone'] == fragment: + await db.market.update_one({"owner": user, "fragments.stone": fragment},{"$inc": {"fragments.$.count": 1}}) + in_list = True + break + if not in_list: + await db.market.update_one({"owner": user}, {"$push": {"fragments": {"stone": fragment, "count": 1}}}) + return True + + for x in exclude: + if x in fragments: + fragments.remove(x) + if not fragments: + return None + fragment = rnd(fragments) + in_list = False + for frag in post['fragments']: + if fragment == frag['stone']: + await db.market.update_one({"owner": user, "fragments.stone": fragment}, {"$inc": {"fragments.$.count": 1}}) + in_list = True + break + if not in_list: + await db.market.update_one({"owner": user}, {"$push": {"fragments": {"stone": fragment, "count": 1}}}) + return fragment + + async def calc_customers(self, user): + data = await db.market.find_one({"owner": user}) + customers = data['customers'] + ratings = [] + for rating in data['ratings']: + ratings.append(rating['rating']) + avr = round(sum(ratings)/len(ratings)) + count = avr * 10 + count += data['level'] * 20 + if data['advert']: + if data['advert'] == "social_media": + count += 30 + elif data['advert'] == "web_ad": + count += 60 + elif data['advert'] == "tv_media": + count += 100 + elif data['advert'] == "billboard": + count += 125 + if data['level'] > 8: + count +=50 + if data['level'] > 10: + count +=50 + if 'endearing' in data['stones']: + n_c = round(count*1.13) + count = n_c + if data['customers'] >= 500 and not 'fivehundred_customers' in data['awards']: + award = await self.get_award(user, "fivehundred_customers") + elif data['customers'] >= 1500 and not 'fifteenhundred_customers' in data['awards']: + award = await self.get_award(user, "fifteenhundred_customers") + elif data['customers'] >= 3000 and not 'threethousand_customers' in data['awards']: + award = await self.get_award(user, "threethousand_customers") + elif data['customers'] >= 5000 and not 'fivethousand_customers' in data['awards']: + award = await self.get_award(user, "fivethousand_customers") return count async def update_data(self, user, country, name, desc): @@ -1377,21 +2478,96 @@ async def update_data(self, user, country, name, desc): "name":name, "description":desc, "customers":0, + "customers_per_day": 0, "laststock": "Has not worked yet.", "id":id, - "logo_url":None, + "logo_url": None, + "banner": None, "ratings":[{"rating":5, "user":0}], "exp":0, + "total_exp": 0, "level": 1, + "luck": 1, "inventory":[], "colour": None, "banner": None, "worker": None, "worker_name": None, + "chef": None, + "notifications": False, "task_list": [], - "tasks": [] + "tasks": [], + "tasks_completed": 0, + "awards": [], + "customers_per_day": 0, + "bonuses": [], + "advert": None, + "special": None, + "stones": [], + "fragments": [] + } - db.market.insert_one(post) + await db.market.insert_one(post) + + class ButtonView(discord.ui.View): + def __init__(self, bot, user_id, cog): + super().__init__(timeout=60) + self.bot = bot + self.user_id = user_id + self.cog = cog + + @discord.ui.button(label="📃 Menu", style=discord.ButtonStyle.secondary) + async def button_callback(self, interac: discord.Interaction, button: discord.ui.Button): + try: + await interac.response.defer() + post = await db.market.find_one({"owner": self.user_id}) + if not post: + await interac.followup.send("Error getting menu info.", ephemeral=True) + return + clr = post.get('colour', 0x8980d9) + embed = discord.Embed(color=clr) + country = str(post['country']) + embed.set_author(icon_url=self.cog.flags.get(country, ''), name=f"{post['name']}'s Menu") + desc = "" + for x in post['items']: + desc += f"{x['name']} | <:BistroBux:1324936072760786964>{x['price']} | {x['sold']} Sold\n"#| {x['stock']} in Stock + embed.description = desc + if post['colour']: + if post['colour'] == 0x171717: + embed.colour = random.randint(0, 0xFFFFFF) + else: + embed.colour = post['colour'] + await interac.followup.send(embed=embed) + except Exception as e: + print(dir(interac), interac) + error = getattr(e, 'original', e) + error_message = traceback.format_exc() + e = ''.join(traceback.format_exception(type(error), error, error.__traceback__, chain=False)) + print(e) + + class SpecialDropdown(discord.ui.Select): + def __init__(self, ctx, post): + options = [] + self.ctx = ctx + for x in post['items']: + options.append(discord.SelectOption(label=x['name'])) + super().__init__(placeholder="Choose an special item...", max_values=1, min_values=1, options=options) + + async def callback(self, interaction: discord.Interaction): + if self.ctx.author.id == interaction.user.id: + await interaction.response.send_message(f"<:CheckMark:1330789181470937139> **{self.values[0]}** has been selected as your restaurant special.", ephemeral=True) + await db.market.update_one({"owner": interaction.user.id}, {"$set": {"special": self.values[0]}}) + await interaction.message.delete() + try: + await self.ctx.message.delete() + except: + pass + + class DropdownView(discord.ui.View): + def __init__(self, ctx, post, cog): + super().__init__() + self.add_item(cog.SpecialDropdown(ctx, post)) + async def setup(bot): await bot.add_cog(Shop(bot)) diff --git a/cogs/tasks.py b/cogs/tasks.py index aea10cf..3e6094b 100644 --- a/cogs/tasks.py +++ b/cogs/tasks.py @@ -1,55 +1,104 @@ import discord from discord.ext import commands, tasks import datetime -import requests -import random -import math -import time -from discord.ext.commands import errors, converter -from random import choice, randint -from random import choice, randint as rnd -import aiohttp import asyncio -import json -import os +from motor.motor_asyncio import AsyncIOMotorClient import config -from pymongo import MongoClient import pymongo -client = MongoClient(config.mongo_client) +client = AsyncIOMotorClient(config.mongo_client) db = client['siri'] class Tasks(commands.Cog): def __init__(self, bot): self.bot = bot - self.pay.start() + self.daily_task.start() def cog_unload(self): - self.pay.cancel() + self.daily_task.cancel() - @tasks.loop(minutes=1440) - async def pay(self): - all = db.market.find() - for x in all: + @tasks.loop(hours=24) + async def daily_task(self): + current_time = datetime.datetime.now() + if current_time.hour == 1 and current_time.minute == 0: + await self.add_customers() + all_users = db.market.find({'worker': {'$exists': True}}) + bulk_updates = [] + async for x in all_users: + if 'worker' in x and x['worker']: + wn = x['worker_name'] + if wn in x['worker']: + cash = x['worker'][wn][2]['pay'] + bulk_updates.append(pymongo.UpdateOne({'owner': x['owner']}, {'$inc': {'money': cash}})) + if x['advert']: + bulk_updates.append(pymongo.UpdateOne({'owner': x['owner']}, {'$set': {'advert': None}})) + if bulk_updates: + try: + result = await db.market.bulk_write(bulk_updates) + print('\x1b[1;36;40m' + '[UPDATE]: ' + '\x1b[0m' + 'All Restaurants have been paid & customers added.') + except Exception as e: + print(f"Error during bulk_write: {e}") + + @daily_task.before_loop + async def before_daily_task(self): + current_time = datetime.datetime.now() + target_time = current_time.replace(hour=1, minute=0, second=0, microsecond=0) + if current_time > target_time: + target_time += datetime.timedelta(days=1) + wait_time = (target_time - current_time).total_seconds() + print(f'\nConnecting..\n\nDaily Tasks will be done in {round(wait_time/60)} minutes.\n------') + await asyncio.sleep(wait_time) + + async def add_money(self, user: int, count: int): + data = await db.market.find_one({"owner": user}) + if data: + bal = data['money'] + money = int(bal) + count + await db.market.update_one({"owner": user}, {"$set": {"money": money}}) + + async def calc_customers(self, user: int): + data = await db.market.find_one({"owner": user}) + if data: + ratings = [rating['rating'] for rating in data['ratings']] + avr = round(sum(ratings) / len(ratings)) if ratings else 0 + count = avr * 10 + data['level'] * 20 + if data['advert']: + if data['advert'] == "social_media": + count += 30 + elif data['advert'] == "web_ad": + count += 60 + elif data['advert'] == "tv_media": + count += 100 + elif data['advert'] == "billboard": + count += 125 + if data['level'] > 8: + count +=50 + if data['level'] > 10: + count +=50 + if 'endearing' in data['stones']: + n_c = round(count*1.13) + count = n_c + return count + else: + return 0 + + async def add_customers(self): + all_users = db.market.find() + bulk_updates = [] + async for x in all_users: + per_day = await self.calc_customers(x['owner']) + current = x['customers'] + bulk_updates.append( + pymongo.UpdateOne( + {'owner': x['owner']}, + {'$inc': {'customers': per_day}} + ) + ) + if bulk_updates: try: - if 'worker' in x: - if x['worker']: - wn = x['worker_name'] - cash = x['worker'][wn][1]['pay'] - await self.add_money(user=x['owner'], count=cash) - except: - pass - print('\x1b[1;36;40m' + '[UPDATE]: ' + '\x1b[0m' + 'All Restaurants have been paid.') - - @pay.before_loop - async def before_pay(self): - await self.bot.wait_until_ready() - - async def add_money(self, user:int, count): - data = db.market.find_one({"owner": user}) - bal = data['money'] - money = int(bal) + count - db.market.update_one({"owner": user}, {"$set":{"money": money}}) + result = await db.market.bulk_write(bulk_updates) + except Exception as e: + print(f"Error during bulk_write for customers: {e}") async def setup(bot): await bot.add_cog(Tasks(bot)) diff --git a/cogs/user.py b/cogs/user.py index e1e20fa..119b432 100644 --- a/cogs/user.py +++ b/cogs/user.py @@ -1,6 +1,7 @@ import discord from discord.ext import commands, tasks import datetime +from datetime import timedelta, datetime as dttm import random import math import time @@ -10,46 +11,35 @@ import asyncio import json import os +import responses +from pytz import timezone, utc +import pytz import config -from pymongo import MongoClient +from pymongo import MongoClient, ASCENDING import pymongo import string -import food +from food import food import requests +import motor.motor_asyncio import trivia +import awards +import songs +from discord.ui import View, Button -#mongo -client = MongoClient(config.mongo_client) +client = motor.motor_asyncio.AsyncIOMotorClient(config.mongo_client) db = client['siri'] -#discoin -#loop = asyncio.get_event_loop() -#client = Client(config.discoin_token, "RBC", loop=loop) + +db.events.create_index([("expireAt", 1)], expireAfterSeconds=0) + + +bbux = "<:BistroBux:1324936072760786964>" + class User(commands.Cog): def __init__(self, bot): self.bot = bot - self.prefix = 'r!' - - #def cog_unload(self): - #self.discoin_update.cancel() - - #@tasks.loop(minutes=4.0) - #async def discoin_update(self): - #await self.bot.wait_until_ready() - #await asyncio.sleep(1) - - #unhandled_transactions = await self.discoin_client.fetch_transactions() - #for transaction in unhandled_transactions: - #await self.discoin_client.handle_transaction(transaction.id) - #user = self.bot.fetch_user(transaction.user_id) - #await self.add_money(user=transaction.user_id, count=round(transaction.payout)) - #if not self.discoin_off and user: - #po = round(transaction.payout) - #cid = transaction.currency_from.id - #tid = transaction.id - #embed = discord.Embed(colour=0xa82021, title="Transaction successful", description=f"Your transfer from **{cid}** to **RBC** has been processed! You have received ${po}.\n\n[Transaction Receipt](https://dash.discoin.zws.im/#/transactions/{tid}/show)") - #await user.send(embed=embed) + self.prefix = 'b.' @commands.Cog.listener() async def on_message(self, message): @@ -62,13 +52,22 @@ async def on_message(self, message): async def user(self, ctx, user:discord.User=None): if not user: user = ctx.author - post = db.market.find_one({"owner": int(user.id)}) + post = await db.market.find_one({"owner": int(user.id)}) if post: - embed = discord.Embed(colour=0xa82021, description=str(user)) - embed.set_author(icon_url=user.avatar_url_as(format='png'), name="User Stats") - embed.set_thumbnail(url=user.avatar_url_as(format='png')) + embed = discord.Embed(colour=0x8980d9, description=str(user)) + if post['colour']: + if post['colour'] == 0x171717: + embed.colour = random.randint(0, 0xFFFFFF) + else: + embed.colour = post['colour'] + embed.set_author(icon_url=user.avatar.url, name="User Stats") + embed.set_thumbnail(url=user.avatar.url) + if post['banner']: + embed.set_image(url=post['banner']) embed.add_field(name="Restaurant", value=post['name'] + f" (Level {post['level']})") - embed.add_field(name="Money", value="$" + str(post['money'])) + embed.add_field(name="Money", value="<:BistroBux:1324936072760786964>" + str(post['money'])) + embed.add_field(name="Luck", value=f"LVL {post['luck']}") + embed.set_footer(text=f"User ID: {post['id']}") await ctx.send(embed=embed) else: await ctx.send("<:RedTick:653464977788895252> This user doesn't have a restaurant") @@ -78,49 +77,57 @@ async def user(self, ctx, user:discord.User=None): async def balance(self, ctx, user:discord.User=None): if not user: user = ctx.author - post = db.market.find_one({"owner": int(user.id)}) + post = await db.market.find_one({"owner": int(user.id)}) if post: bal = format(post['money'], ",d") - await ctx.send(f"**{user.name}**'s balance is **${bal}**.") + await ctx.send(f"**{user.name}**'s balance is **<:BistroBux:1324936072760786964>{bal}**.") else: await ctx.send("<:RedTick:653464977788895252> This user doesn't have a restaurant") @commands.command(pass_context=True) @commands.cooldown(1, 5, commands.BucketType.user) async def donate(self, ctx, user: discord.User=None, count:int=None): - posts_user = db.market.find_one({"owner": user.id}) - posts = db.market.find_one({"owner": ctx.author.id}) + posts = await db.market.find_one({"owner": ctx.author.id}) if ctx.author == user: await ctx.send("<:RedTick:653464977788895252> You cannot donate money to yourself!") elif not count or not user: - await ctx.send("<:RedTick:653464977788895252> You must include both the user and the amount of money. Example: `r!donate @lukee#0420 25`") + await ctx.send("<:RedTick:653464977788895252> You must include both the user and the amount of money. Example: `b.donate @paixlukee 25`") elif count < 0: - await ctx.send(f"<:RedTick:653464977788895252> You can't donate under **$1**.") + await ctx.send(f"<:RedTick:653464977788895252> You can't donate under **<:BistroBux:1324936072760786964>1**.") elif not posts['money'] >= count: await ctx.send(f"<:RedTick:653464977788895252> You don't have enough money.") - elif posts_user is None: - await ctx.send(f"<:RedTick:653464977788895252> **{user.name}** doesn't have a restaurant.") - elif not posts is None: + elif posts: + posts_user = await db.market.find_one({"owner": user.id}) + if not posts_user: + await ctx.send(f"<:RedTick:653464977788895252> **{user.name}** doesn't have a restaurant.") + return await self.add_money(user=user.id, count=count) await self.take_money(user=ctx.author.id, count=count) - await ctx.send(f"{user.mention}, **{ctx.message.author}** has donated **${count}** to you.") + await ctx.send(f"{user.mention}, **{ctx.message.author}** has donated **<:BistroBux:1324936072760786964>{count}** to you.") + if "donate_money" in posts['tasks']: + user = posts + ix = user['tasks'].index("donate_money") + if user['task_list'][ix]['completed']+1 == 1: + await ctx.author.send(f"You have completed the **{user['task_list'][ix]['description']}** task. You have been awarded **{user['task_list'][ix]['rewards']} EXP**.") + await self.add_exp(user=ctx.author.id, count=user['task_list'][ix]['rewards'], multiplier=False) + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "donate_money"},{"$set": {"task_list.$.completed": 1}}) else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `b.start`.") @commands.command(pass_context=True, aliases=['Daily']) @commands.cooldown(1,86400, commands.BucketType.user) async def daily(self, ctx): - posts = db.market.find_one({"owner": ctx.author.id}) - patrons = db.utility.find_one({"utility": "patrons"}) + posts = await db.market.find_one({"owner": ctx.author.id}) + patrons = await db.utility.find_one({"utility": "patrons"}) if posts: ri = random.randint(1,6) - rci = random.randint(140, 200) + rci = random.randint(100, 150) if ctx.author.id in patrons['bronze']: rci *= 1.2 rci = round(rci) @@ -133,44 +140,77 @@ async def daily(self, ctx): elif ctx.author.id in patrons['diamond']: rci *= 1.7 rci = round(rci) - if 'worker' in posts: - if posts['worker']: - rci = rci - 50 + if posts['worker']: + rci -= 50 + if posts['chef']: + if posts['chef'] == "m": + rci -= 20 + else: + rci -= 40 + if posts['customers'] > 2000: + add_on = 150 + elif posts['customers'] > 1600: + add_on = 120 + elif posts['customers'] > 800: + add_on = 90 + elif posts['customers'] > 300: + add_on = 40 else: - pass - chest = [f'• {rci} Cash'] - if ri == 1: - pass - #chest.append('• Cooldown Remover Potion (1x)') - #db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"potion": "cooldown"}}}) + add_on = 30 + rci += add_on + + chest = [f'{rci} Cash'] + if random.randint(1,11) == 1: + frag = await self.add_rand_fragment(ctx.author.id) + if frag: + if frag == 'agility': + emoji = '<:AgilityFragment:1331502143760236574>' + elif frag == 'opportunity': + emoji = '<:OpportunityFragment:1331505178959937556>' + elif frag == 'endearing': + emoji = '<:EndearingFragment:1331823626080620574>' + elif frag == 'ambience': + emoji = '<:AmbienceFragment:1331825947036483675>' + embed = discord.Embed(colour=0x8980d9, description=f"* {emoji} Fragment of {frag.capitalize()}\n\nWant even more? Vote for me on [Discord Bot List](https://top.gg/bot/648065060559781889), and do `b.votereward` to receive another chest.") + embed.set_thumbnail(url="http://pixelartmaker.com/art/f6d46bd306aacfd.png") + embed.set_footer(text="Come back in 24 hours!") + if posts['colour']: + embed.colour = posts['colour'] + await ctx.send(embed=embed, content=f"{ctx.author.mention}, you opened your daily chest and received...") + else: + await self.add_money(user=ctx.author.id, count=rci) + embed = discord.Embed(colour=0x8980d9, description="* "+"\n *".join(chest) + "\n\nWant even more money? Vote for me on [Discord Bot List](https://top.gg/bot/648065060559781889), and do `b.votereward` to receive another chest.") + embed.set_thumbnail(url="http://pixelartmaker.com/art/f6d46bd306aacfd.png") + embed.set_footer(text="Come back in 24 hours!") + if posts['colour']: + embed.colour = posts['colour'] + await ctx.send(embed=embed, content=f"{ctx.author.mention}, you opened your daily chest and received...") else: - pass - try: - await self.add_money(user=ctx.author.id, count=rci) - embed = discord.Embed(colour=0xa82021, description="\n".join(chest) + "\n\nWant even more money? Vote for me on [Discord Bot List](https://top.gg/bot/648065060559781889), and do `r!votereward` to receive another chest.") - embed.set_thumbnail(url="http://pixelartmaker.com/art/f6d46bd306aacfd.png") - embed.set_footer(text="Come back in 24 hours!") - await ctx.send(embed=embed, content=f"{ctx.author.mention}, you opened your daily chest and received...") - except Exception as e: - await ctx.send("<:RedTick:653464977788895252> An error has occurred! The cooldown has been lifted. `{e}`") - self.bot.get_command("daily").reset_cooldown(ctx) - except: - await ctx.send("<:RedTick:653464977788895252> An unknown error has occurred! The cooldown has been lifted.") - self.bot.get_command("daily").reset_cooldown(ctx) + try: + await self.add_money(user=ctx.author.id, count=rci) + embed = discord.Embed(colour=0x8980d9, description="* "+"\n *".join(chest) + "\n\nWant even more money? Vote for me on [Discord Bot List](https://top.gg/bot/648065060559781889), and do `b.votereward` to receive another chest.") + embed.set_thumbnail(url="http://pixelartmaker.com/art/f6d46bd306aacfd.png") + embed.set_footer(text="Come back in 24 hours!") + if posts['colour']: + embed.colour = posts['colour'] + await ctx.send(embed=embed, content=f"{ctx.author.mention}, you opened your daily chest and received...") + except: + await ctx.send("<:RedTick:653464977788895252> An unknown error has occurred! The cooldown has been lifted.") + self.bot.get_command("daily").reset_cooldown(ctx) else: - await ctx.send("You don't have a restaurant. Create one by doing `r!start`.") + await ctx.send("You don't have a restaurant. Create one by doing `b.start`.") @commands.command(aliases=['Inventory', 'inv']) async def inventory(self, ctx, page=1): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) if post: - embed = discord.Embed(colour=0xa82021) - embed.set_author(icon_url=ctx.author.avatar_url_as(format='png'), name="Your Inventory") + embed = discord.Embed(colour=0x8980d9) + embed.set_author(icon_url=ctx.author.avatar.url, name="Your Inventory") names = [] items_per_page = 12 - pages = math.ceil(len(post['inventory']) / 12) - start = (page - 1) * 12 - end = start + 12 + pages = math.ceil(len(post['inventory']) / items_per_page) + start = (page - 1) * items_per_page + end = start + items_per_page for x in post['inventory'][start:end]: if 'colour' in x: names.append(f"<:ColourIcon:659418340703469584> {x['colour']['colour']} ({x['colour']['rarity']})") @@ -180,39 +220,130 @@ async def inventory(self, ctx, page=1): names.append(f"<:CooldownPotion:715822985780658238> Cooldown Remover Potion (Uncommon)") elif 'item' in x: if x['item'] == 'fish': - names.append(f":fishing_pole_and_fish: Fishing Rod (Common)") + names.append(f":<:FishingRod:1333893065542336523> Fishing Rod (Common)") elif x['item'] == 'ep': names.append(f"<:ExperiencePotion:715822985780658238> Experience Potion (Common)") + elif x['item'] == 'tm': + names.append(f"<:TimeMachine:1333889857688436847> Time Machine (Common)") + elif x['item'] == 'fe': + names.append(f"<:FireExtinguisher:1333891774472523888> Fire Extinguisher (Common)") + elif x['item'] == 'ambience': + names.append("<:AmbienceStone:1331825641703604225> Stone of Ambience (Legendary)") else: pass if names: embed.description = "\n".join(names) else: embed.description = "Nothing to see here." - np = page+1 - embed.set_footer(text=f"Page {page} of {pages} | r!inventory {np} to see the next page") - await ctx.send(embed=embed) + + np = page + 1 + embed.set_footer(text=f"Page {page} of {pages}") + + # Pagination buttons + prev_button = Button(label="←", custom_id="prev_page", style=discord.ButtonStyle.primary) + next_button = Button(label="→", custom_id="next_page", style=discord.ButtonStyle.primary) + + if page == 1: + prev_button.disabled = True + if page == pages: + next_button.disabled = True + + prev_button.callback = lambda interaction: self.inv_button_callback(interaction, ctx) + next_button.callback = lambda interaction: self.inv_button_callback(interaction, ctx) + + view = View() + view.add_item(prev_button) + view.add_item(next_button) + + await ctx.send(embed=embed, view=view) else: - await ctx.send("You don't have a restaurant! Create one with `r!start`.") + await ctx.send("You don't have a restaurant! Create one with `b.start`.") + + async def inv_button_callback(self, interaction, ctx): + footer_text = interaction.message.embeds[0].footer.text + current_page = int(footer_text.split("Page ")[1].split(" of")[0]) + + if interaction.user != ctx.author: + return + + if interaction.data['custom_id'] == 'next_page': + await self.show_inventory_page(ctx, current_page + 1, interaction) + elif interaction.data['custom_id'] == 'prev_page' and not current_page == 1: + await self.show_inventory_page(ctx, current_page - 1, interaction) + + async def show_inventory_page(self, ctx, page, interaction): + post = await db.market.find_one({"owner": ctx.author.id}) + if post: + embed = discord.Embed(colour=0x8980d9) + embed.set_author(icon_url=ctx.author.avatar.url, name="Your Inventory") + names = [] + items_per_page = 12 + pages = math.ceil(len(post['inventory']) / items_per_page) + start = (page - 1) * items_per_page + end = start + items_per_page + for x in post['inventory'][start:end]: + if 'colour' in x: + names.append(f"<:ColourIcon:659418340703469584> {x['colour']['colour']} ({x['colour']['rarity']})") + elif 'banner' in x: + names.append(f"<:BannerIcon:657457820295495699> {x['banner']['name']} ({x['banner']['rarity']}) [[View]]({x['banner']['url']})") + elif 'potion' in x: + names.append(f"<:CooldownPotion:715822985780658238> Cooldown Remover Potion (Uncommon)") + elif 'item' in x: + if x['item'] == 'fish': + names.append(f"<:FishingRod:1333893065542336523> Fishing Rod (Common)") + elif x['item'] == 'ep': + names.append(f"<:ExperiencePotion:715822985780658238> Experience Potion (Common)") + elif x['item'] == 'tm': + names.append(f"<:TimeMachine:1333889857688436847> Time Machine (Common)") + elif x['item'] == 'fe': + names.append(f"<:FireExtinguisher:1333891774472523888> Fire Extinguisher (Common)") + elif x['item'] == 'ambience': + names.append("<:AmbienceStone:1331825641703604225> Stone of Ambience (Legendary)") + else: + pass + if names: + embed.description = "\n".join(names) + else: + embed.description = "Nothing to see here." + + embed.set_footer(text=f"Page {page} of {pages}") + + prev_button = Button(label="←", custom_id="prev_page", style=discord.ButtonStyle.primary) + next_button = Button(label="→", custom_id="next_page", style=discord.ButtonStyle.primary) + + if page == 1: + prev_button.disabled = True + if page == pages: + next_button.disabled = True + + prev_button.callback = lambda interaction: self.inv_button_callback(interaction, ctx) + next_button.callback = lambda interaction: self.inv_button_callback(interaction, ctx) + + view = View() + view.add_item(prev_button) + view.add_item(next_button) + + await interaction.response.edit_message(embed=embed, view=view) + @commands.command(aliases=['Dine', 'Eat', 'eat']) - @commands.cooldown(1,45, commands.BucketType.user) + @commands.cooldown(1, 35, commands.BucketType.user) async def dine(self, ctx, *, restaurant=None): - post = db.market.find_one({"owner":ctx.author.id}) + post = await db.market.find_one({"owner":ctx.author.id}) def nc(m): return m.author == ctx.message.author if ctx.message.mentions: if len(ctx.message.mentions) >= 2: - res = db.market.find_one({"owner":ctx.message.mentions[0].id}) + res = await db.market.find_one({"owner":ctx.message.mentions[0].id}) else: - res = db.market.find_one({"owner":ctx.message.mentions[0].id}) - elif db.market.find_one({"name": restaurant}): - res = db.market.find_one({"name": restaurant}) + res = await db.market.find_one({"owner":ctx.message.mentions[0].id}) + elif await db.market.find_one({"name": restaurant}): + res = await db.market.find_one({"name": restaurant}) else: res = None if not restaurant: self.bot.get_command("dine").reset_cooldown(ctx) - await ctx.send("<:RedTick:653464977788895252> You didn't include a restaurant! Example: `r!dine @lukee#0420` or `r!dine McDonalds`.") + await ctx.send("<:RedTick:653464977788895252> You didn't include a restaurant! Example: `b.dine @paixlukee` or `b.dine McDonalds`.") elif res['owner'] == ctx.author.id: self.bot.get_command("dine").reset_cooldown(ctx) await ctx.send("<:RedTick:653464977788895252> You can't dine in at your own restaurant.") @@ -221,7 +352,7 @@ def nc(m): for x in res['items']: items.append(x['name']) li = ', '.join(items) - embed = discord.Embed(colour=0xa82021, description=f"Welcome to {res['name']}!\n\nWhich item would you like to order?\n\n**Menu**: {li}") + embed = discord.Embed(colour=0x8980d9, description=f"Welcome to {res['name']}!\n\nWhich item would you like to order?\n\n**Menu**: {li}") embed.set_footer(text='You have 90 seconds to respond with a menu item.') cmsg = await ctx.send(embed=embed) chi = await self.bot.wait_for('message', check=nc, timeout=90) @@ -248,23 +379,33 @@ def nc(m): p = '.' await ctx.send(f"{dinemsg}{p} You've earned {c} EXP for dining in.") else: - await ctx.send(f"You've ordered a {item['name']} from {res['name']} for ${item['price']}. You've earned {c} EXP for dining in.") + await ctx.send(f"You've ordered a {item['name']} from {res['name']} for <:BistroBux:1324936072760786964>{item['price']}. You've earned {c} EXP for dining in.") price_paid = round(item['price']/1.8) await self.add_money(res['owner'], round(item['price']/1.8)) await self.add_sold(res['owner'], item['name']) + current_customers = res['customers'] + await db.market.update_one({"owner": res['owner']}, {"$set": {"customers": current_customers+1}}) + if 'notifications' in res: if res['notifications']: if item['name'].startswith(("a", "e", "i", "o", "u")): nn = "an " + item['name'] else: nn = "a " + item['name'] - nemb = discord.Embed(title="Dine-in Notification", description=f"Someone came to your restaurant and ordered {nn}. You have been paid ${price_paid}.") - nemb.set_footer(text="To turn these notifications off, do 'r!set notifications'") + nemb = discord.Embed(title="Dine-in Notification", description=f"Someone came to your restaurant and ordered {nn}. You have been paid <:BistroBux:1324936072760786964>{price_paid}.") + nemb.set_footer(text="To turn these notifications off, do 'b.set notifications'") await self.bot.get_user(res['owner']).send(embed=nemb) + + if "dine_fifty" in post['tasks']: + user = post + ix = user['tasks'].index("dine_fifty") + if user['task_list'][ix]['completed']+1 == user['task_list'][ix]['total']: + await ctx.author.send(f"You have completed the **{user['task_list'][ix]['description']}** task. You have been awarded **{user['task_list'][ix]['rewards']} EXP**.") + await self.add_exp(user=ctx.author.id, count=user['task_list'][ix]['rewards'], multiplier=False) + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "dine_fifty"},{"$inc": {"task_list.$.completed": 1}}) else: - pass - else: - pass + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "dine_fifty"},{"$inc": {"task_list.$.completed": 1}}) + else: self.bot.get_command("dine").reset_cooldown(ctx) await ctx.send("<:RedTick:653464977788895252> You don't have enough money for this.") @@ -276,20 +417,21 @@ def nc(m): await ctx.send("<:RedTick:653464977788895252> I couldn't find that restaurant. Try tagging the owner instead.") @commands.command(aliases=['Use']) - @commands.cooldown(1,10, commands.BucketType.user) + @commands.cooldown(1,8, commands.BucketType.user) async def use(self, ctx, *, item): - post = db.market.find_one({"owner": ctx.author.id}) - item = item.lower().replace("(uncommon", "").replace("(common)", "").replace("uncommon", "").replace("common", "") - #w = True + post = await db.market.find_one({"owner": ctx.author.id}) + item = item.lower().replace("(uncommon)", "").replace("(common)", "").replace("uncommon", "").replace("common", "") + is_banner = False if post: w = [] + no_fire = False for x in post['inventory']: if 'colour' in x: if w: pass elif x['colour']['colour'].lower() == item.lower(): await asyncio.sleep(1) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"colour": x['colour']['hex']}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"colour": x['colour']['hex']}}) w.append(' ') else: pass @@ -299,7 +441,9 @@ async def use(self, ctx, *, item): elif x['banner']['name'].lower() == item.lower(): await asyncio.sleep(1) url = x['banner']['url'].replace('paixlukee.ml', 'paixlukee.dev') - db.market.update_one({"owner": ctx.author.id}, {"$set": {"banner": url}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"banner": url}}) + award = await self.get_award(ctx.author.id, "set_banner") + is_banner = True w.append(' ') else: pass @@ -307,56 +451,64 @@ async def use(self, ctx, *, item): if w: pass elif item == 'fish': - await ctx.send("Incorrect Usage... Try the `r!fish` command!") + await ctx.send("Incorrect Usage... Try the `b.fish` command!") elif item == 'experience potion': if {"item": "ep"} in post['inventory']: - w.append('+50 EXP has been added to your Restaurant.') - await self.add_exp(user=ctx.author.id, count=50) - db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory":{"item": "ep"}}}) + w.append('+50 EXP has been added to your restaurant.') + await self.add_exp(user=ctx.author.id, count=50, multiplier=False) + await db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory":{"item": "ep"}}}) else: - pass#await ctx.send("<:RedTick:653464977788895252> You do not have any Experience Potions in your inventory!") - else: - pass - - - - elif 'potion' in x: - if not w: - if x['potion'] == 'cooldown': - def nc(m): - return m.author == ctx.message.author - embed = discord.Embed(colour=0xa82021, description=f"What command would you like to use this potion on? `Ex. daily`") - embed.set_footer(text="You have 90 seconds to reply") - embed.set_author(name="Cooldown Remover Potion", icon_url="https://cdn.discordapp.com/emojis/715822985780658238.png?v=1") - msg = await ctx.send(embed=embed) - resp = await self.bot.wait_for('message', check=nc, timeout=90) - try: - await resp.delete() - await msg.delete() - except: - pass - if not self.bot.get_command(resp.content.lower()): - await ctx.send("<:RedTick:653464977788895252> Error using potion, did you type it right? `Example: daily`") - w.append(1) + pass + elif item == 'time machine': + to_reset = ["fish", "trivia"] + to_reset_dyna = ["cook", "work", "clean", "beg"] + if {"item": "tm"} in post['inventory']: + for command in to_reset: + cmd = self.bot.get_command(command) + cmd.reset_cooldown(ctx) + for cmd in to_reset_dyna: + result = await db.cooldowns.find_one({"user_id": ctx.author.id, "command_name": cmd}) + if result: + await db.cooldowns.delete_one({"user_id": ctx.author.id, "command_name": cmd}) + + await db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory":{"item": "tm"}}}) + w.append("All cooldowns have been reset (excluding daily & weekly).") + else: + pass + elif item == 'fire extinguisher': + if {"item": "fe"} in post['inventory']: + if 'fire' in post['bonuses']: + w.append("Your restaurant is no longer on fire.") + await db.market.update_one({"owner": ctx.author.id}, {"$pull": {"bonuses": "fire"}}) + await db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory":{"item": "fe"}}}) else: - self.bot.get_command(resp.content.lower()).reset_cooldown(ctx) - await ctx.send("Item used successfully.") - db.market.update_one({"owner": ctx.author.id}, {"$pull": {"inventory":{"potion": "cooldown"}}}) - w.append(1) + no_fire = True + w.append(" ") + else: + pass + + elif item == 'ambience' or item == 'stone of ambience': + w.append('Messages will now switch between random colors.') + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"colour": 0x171717}}) else: pass else: pass if not w: await ctx.send(f"<:RedTick:653464977788895252> I could not find that in your inventory. Please only include the item name.") + elif no_fire: + await ctx.send(f"<:RedTick:653464977788895252> Your restaurant is not on fire.") else: await ctx.send(f"Item used successfully. {w[0]}") + if is_banner: + if award: + await ctx.send(f"{ctx.author.mention}, You've earned the {awards.awards["set_banner"]["emoji"]} **Marketing Expert** award for setting a banner for the first time!") else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.start`.") @commands.command(aliases=['Se2ll']) async def se2ll(self, ctx, *, item): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) item = item.lower().replace("(uncommon", "").replace("(common)", "").replace("uncommon", "").replace("common", "") w = True if post: @@ -364,11 +516,11 @@ async def se2ll(self, ctx, *, item): if 'colour' in x: if x['colour']['colour'].lower() == item: await asyncio.sleep(1) - db.market.update_one({"owner": ctx.author.id}, {"$set": {"colour": None}}) + await db.market.update_one({"owner": ctx.author.id}, {"$set": {"colour": None}}) elif 'banner' in x: if x['banner']['name'].lower() == item: await asyncio.sleep(1) - db.market.delete_one({"owner": ctx.author.id}, {"$set": {"banner": None}}) + await db.market.delete_one({"owner": ctx.author.id}, {"$set": {"banner": None}}) else:#if 'boost' in x: w = False#names.append() if not w: @@ -376,12 +528,12 @@ async def se2ll(self, ctx, *, item): else: await ctx.send("Item sold successfully for") else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.start`.") @commands.command(pass_context=True, aliases=['Votereward']) @commands.cooldown(1, 43200, commands.BucketType.user) async def votereward(self, ctx): #http://pixelartmaker.com/art/f697739d6ed8a4b.png - posts = db.market.find_one({"owner": ctx.author.id}) + posts = await db.market.find_one({"owner": ctx.author.id}) rci = random.randint(100,150) r = requests.get(f"https://discordbots.org/api/bots/648065060559781889/check?userId={ctx.author.id}", headers={"Authorization": config.dbl_token}).json() if posts: @@ -395,16 +547,49 @@ async def votereward(self, ctx): #http://pixelartmaker.com/art/f697739d6ed8a4b.p await ctx.send("You haven't upvoted! Upvote here: ") self.bot.get_command("votereward").reset_cooldown(ctx) else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `b.start`.") + + @commands.command(aliases=['Karaoke']) + @commands.cooldown(1, 30, commands.BucketType.user) + async def karaoke(self, ctx): + post = await db.market.find_one({"owner": ctx.author.id}) + event = await db.events.find_one({"user_id": ctx.author.id}) + if not post: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `b.start`.") + return + if event: + if event['type'] == 'kn': + rms = rnd(songs.lyrics) + embed = discord.Embed(colour=0x8980d9, description=f':notes: **Guess the Song!**\n\n**"**{rms['lyric']}**"**') + embed.set_footer(text="Respond with the song name.") + await ctx.send(embed=embed) + b = time.perf_counter() + resp = await self.bot.wait_for('message', check=lambda x: x.author == ctx.author) + a = time.perf_counter() + tm = a-b + if resp.content.lower() == rms['song'].lower(): + if tm < 6: + exp = 20 + else: + exp = 15 + await ctx.send(f"{ctx.author.mention}, you guessed correctly! You have been awarded {exp} EXP!") + await self.add_exp(ctx.author.id, exp) + else: + await ctx.send(f"{ctx.author.mention}, you guessed incorrectly! It was **{rms['song']}**") + else: + await ctx.send("<:RedTick:653464977788895252> You don't have an ongoing Karaoke event! Do `b.event` for more details.") + + @commands.command(aliases=['Trivia']) - @commands.cooldown(1, 30, commands.BucketType.user) + @commands.cooldown(1, 45, commands.BucketType.user) async def trivia(self, ctx): - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) if not post: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.start`.") else: - embed = discord.Embed(colour=0xa82021) + embed = discord.Embed(colour=0x8980d9) + footer = None question = rnd(trivia.questions) letters = ["a", "b", "c", "d"] cn = 0 @@ -426,119 +611,239 @@ async def trivia(self, ctx): opt.append(f":regional_indicator_{x['letter']}: {x[letter]}") answers = "\n".join(opt) embed.description = question['question'] + "\n\n" + answers - embed.set_footer(text="You have 90 seconds to respond with the correct letter.") - await ctx.send(embed=embed) + embed.set_footer(text="You have 90 seconds to answer.") + if post['colour']: + if post['colour'] == 0x171717: + embed.colour = random.randint(0, 0xFFFFFF) + else: + embed.colour = post['colour'] cl = None + msg = None for x in choices: letter = x['letter'] if x[letter] == question['correct']: cl = x['letter'] - b = time.perf_counter() - msg = await self.bot.wait_for('message', check=lambda x: x.author == ctx.author) - a = time.perf_counter() - tt = a-b - if msg.content.lower() == cl or msg.content.lower() == question['correct'].lower(): - if tt <= 5: - await ctx.send("You've answered correctly in under 5 seconds. You've been awarded $10.") - await self.add_money(ctx.author.id, 10) - elif tt <= 10: - await ctx.send("You've answered correctly in under 10 seconds. You've been awarded $8.") - await self.add_money(ctx.author.id, 8) + + opportunity_used = False + second_attempt = False + sa_msg = None + footer = None + + async def t_button_callback(interaction, letter, b): + nonlocal opportunity_used, second_attempt, sa_msg, footer + await interaction.response.defer() + a = time.perf_counter() + tt = a-b + event = await db.events.find_one({"user_id": ctx.author.id}) + if letter == cl or letter == question['correct'].lower(): + wrong = False + if tt <= 5: + money = 12 + resp = "You've answered correctly in under 5 seconds!" + elif tt <= 10: + money = 8 + resp = "You've answered correctly in under 10 seconds!" + else: + money = 5 + resp = "You've answered correctly!" + if event: + if event['type'] == 'ta': + money *= 1.7 + money = round(money) else: - await ctx.send("You've answered correctly. You've been awarded $5.") - await self.add_money(ctx.author.id, 5) - else: - await ctx.send("You've answered incorrectly. You've been awarded $2 for your efforts.") - await self.add_money(ctx.author.id, 2) + wrong = True + if 'opportunity' in post['stones'] and not opportunity_used: + opportunity_used = True + second_attempt = True + wrong = False + resp = "You answered incorrectly, but you have the <:OpportunityStone:1331504493015076914> **Opportunity Stone**! You get another chance!" + money = 0 + if wrong: + if 'apron_uses' in post: + if post['apron_uses']: + uses_left = int(post['apron_uses'])-1 + footer = f"You have {uses_left} Golden Apron uses left." + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"apron_uses": uses_left}}) + description = f"{ctx.author.mention}, You've answered incorrectly! You've been awarded {bbux}2 for your efforts." + await self.add_money(ctx.author.id, 2, check_tasks=True) + else: + if second_attempt: + second_attempt = False + sa_msg = await ctx.send(resp) + return + if 'apron_uses' in post: + if post['apron_uses']: + uses_left = int(post['apron_uses'])-1 + money = round(money * 1.25) + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"apron_uses": uses_left}}) + footer = f"You have {uses_left} Golden Apron uses left." + await self.add_money(ctx.author.id, money, check_tasks=True) + description = f"{ctx.author.mention}, {resp} You've been awarded {bbux}{money}." + embed2 = discord.Embed(colour=0x8980d9, description=description) + if footer: + embed2.set_footer(text=footer, icon_url="https://media.discordapp.net/attachments/1325282246181130330/1329660286302687257/New_Piskel.gif?ex=678b2624&is=6789d4a4&hm=6475df9cb8e5d82646fed8347eb825403e890f45061b28848b477d4e19ace3ce&=&width=1178&height=1060") + await ctx.send(embed=embed2) + if msg: + await msg.delete() + if sa_msg: + await sa_msg.delete() + try: + await interaction.message.delete() + except: + pass + + b = time.perf_counter() + a_btn = Button(label="A", custom_id="ltr_a", style=discord.ButtonStyle.primary) + b_btn = Button(label="B", custom_id="ltr_b", style=discord.ButtonStyle.primary) + c_btn = Button(label="C", custom_id="ltr_c", style=discord.ButtonStyle.primary) + d_btn = Button(label="D", custom_id="ltr_d", style=discord.ButtonStyle.primary) + + a_btn.callback = lambda interaction: t_button_callback(interaction, "a", b) + b_btn.callback = lambda interaction: t_button_callback(interaction, "b", b) + c_btn.callback = lambda interaction: t_button_callback(interaction, "c", b) + d_btn.callback = lambda interaction: t_button_callback(interaction, "d", b) + view = View() + view.add_item(a_btn) + view.add_item(b_btn) + view.add_item(c_btn) + view.add_item(d_btn) + + msg = await ctx.send(embed=embed, view=view) - @commands.command(aliases=['Beg']) - @commands.cooldown(1, 70, commands.BucketType.user) + + @commands.command(aliases=['Beg', 'loan', 'Loan']) async def beg(self, ctx): - numb = random.randint(1,5) - post = db.market.find_one({"owner": ctx.author.id}) + post = await db.market.find_one({"owner": ctx.author.id}) + if post['luck'] > 3: + numb = random.randint(1,5) + elif post['luck'] > 1: + numb = random.randint(1,6) + else: + numb = random.randint(1,7) + bad_resp = ["bad credit score", "unstable income", "criminal record", "unstable employment history"] + if 'agility' in post['stones']: + cd_sec = 95 + else: + cd_sec = 65 + on_cd, remaining = await self.dynamic_cd(ctx.author.id, "beg", cd_sec) + if on_cd: + c_min = int(remaining) // 60 + c_sec = int(remaining) % 60 + m_l = "m " + if not c_min: + c_min = "" + m_l = "" + await ctx.send(f"<:RedTick:653464977788895252> You are on cooldown! Please wait **{c_min}{m_l}{c_sec}s**.") + return if not post: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `r!start`.") - elif numb == 1 or numb == 2: - await ctx.send("The Bank of Restaria denied your request.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant! Create one with `b.start`.") else: - grant = numb*5 - await ctx.send(f"The Bank of Restaria granted you ${grant} for your restaurant.") - await self.add_money(ctx.author.id, grant) + embed = discord.Embed(colour=0x32a852) + embed.set_thumbnail(url="https://media.discordapp.net/attachments/1325282246181130330/1327904413762719755/IMG_2584.png?ex=6784c2db&is=6783715b&hm=696fa2e9b7005a754e975c16485f371a3c6063aebdad7ed23eb48a87a1a2b4a2&=&format=webp&quality=lossless&width=1092&height=1046") + if numb >= 4: + resp = rnd(bad_resp) + embed.description = f"{ctx.author.mention}, you have been denied for a loan due to your {resp}. Try again later!" + else: + grant = random.randint(8, 45) + embed.description = f"{ctx.author.mention}, Bistaria Bank has granted you {bbux}{grant} for your restaurant!" + await self.add_money(ctx.author.id, grant, check_tasks=True) + await ctx.send(embed=embed) @commands.command(aliases=['Donation']) @commands.cooldown(1, 3, commands.BucketType.user) async def donation(self, ctx): - embed = discord.Embed(colour=0xa82021, title="Donate", description="Want to support restaurant AND receive awesome rewards? To donate now or view information on rewards, click [here](https://www.patreon.com/join/paixlukee).") + embed = discord.Embed(colour=0x8980d9, title="Donate", description="Want to support restaurant AND receive awesome rewards? To donate now or view information on rewards, click [here](https://www.patreon.com/join/paixlukee).") await ctx.send(embed=embed) @commands.command(pass_context=True, aliases=['Weekly']) @commands.cooldown(1,604800, commands.BucketType.user) async def weekly(self, ctx): - posts = db.market.find_one({"owner": ctx.author.id}) - patrons = db.utility.find_one({"utility": "patrons"}) + posts = await db.market.find_one({"owner": ctx.author.id}) + patrons = await db.utility.find_one({"utility": "patrons"}) if posts: - rci = random.randint(1000, 1700) - if ctx.author.id in patrons['silver'] or ctx.author.id in patrons['gold'] or ctx.author.id in patrons['diamond']: + rci = random.randint(400, 800) + if patrons and any(patrons.get(key) and ctx.author.id in patrons[key] for key in ['silver', 'gold', 'diamond']): chest = [f'{rci} Cash'] await self.add_money(user=ctx.author.id, count=rci) - embed = discord.Embed(colour=0xa82021, description="\n".join(chest) + "\n\nP.S. Thanks for supporting me!") + embed = discord.Embed(colour=0x8980d9, description="\n".join(chest) + "\n\nP.S. Thanks for supporting me!") embed.set_thumbnail(url="http://pixelartmaker.com/art/134b1292dc645e7.png") embed.set_footer(text="Come back in 1 week!") await ctx.send(embed=embed, content=f"{ctx.author.mention}, you opened your patron weekly chest and received...") else: - await ctx.send("<:RedTick:653464977788895252> You must be a silver+ patron to use this command! For more information on restaurant patronage, click \"Donate\" on the help command.") + await ctx.send("<:RedTick:653464977788895252> You must be a silver+ patron to use this command! For more information on BistroBot patronage, click \"Donate\" on the help command.") self.bot.get_command("weekly").reset_cooldown(ctx) else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `r!start`.") + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one by doing `b.start`.") self.bot.get_command("weekly").reset_cooldown(ctx) @commands.command(aliases=['Work']) - @commands.cooldown(1, 480, commands.BucketType.user) async def work(self, ctx): - posts = db.utility.find_one({"utility": "res"}) - patrons = db.utility.find_one({"utility": "patrons"}) - user = db.market.find_one({"owner": ctx.author.id}) + await ctx.typing() + posts = responses.work + patrons = await db.utility.find_one({"utility": "patrons"}) + user = await db.market.find_one({"owner": ctx.author.id}) + event = await db.events.find_one({"user_id": ctx.author.id}) now = datetime.datetime.now() - celebrities = ["Taylor Swift", "Lady Gaga", "Zac Efron", "6ix9ine", "Brendon Urie", "Tom Holland", "Katy Perry", "Ellen Degeneres", "Logan Paul", "Benedict Cumberpatch", "John Cena", "Miley Cyrus", "Kylie Jenner", "Dua Lipa", "Ariana Grande", "Ryan Gosling", "Selena Gomez", "Shawn Mendes", "Keanu Reeves", "Beyoncé", "Rihanna", "Eminem"] - db.market.update_one({"owner": ctx.author.id}, {"$set":{"laststock": now.strftime("%d/%m/%Y %H:%M")}}) + uses_left = 0 + celebrities = ["Drake", "Taylor Swift", "Lady Gaga", "Zac Efron", "6ix9ine", "Brendon Urie", "Tom Holland", "Katy Perry", "Ellen Degeneres", "Logan Paul", "Benedict Cumberpatch", "John Cena", "Miley Cyrus", "Kylie Jenner", "Dua Lipa", "Ariana Grande", "Ryan Gosling", "Selena Gomez", "Shawn Mendes", "Keanu Reeves", "Beyoncé", "Rihanna", "Eminem", "Gordon Ramsey", "Billie Eilish"] + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"laststock": now.strftime("%d/%m/%Y %H:%M")}}) + if 'agility' in user['stones']: + cd_sec = 350 + else: + cd_sec = 410 + on_cd, remaining = await self.dynamic_cd(ctx.author.id, "work", cd_sec) + if on_cd: + c_min = int(remaining) // 60 + c_sec = int(remaining) % 60 + m_l = "m " + if not c_min: + c_min = "" + m_l = "" + await ctx.send(f"<:RedTick:653464977788895252> You are on cooldown! Please wait **{c_min}{m_l}{c_sec}s**.") + return if user: if ctx.author.id in patrons['bronze']: - ml = 1.2 + ml = 1.15 elif ctx.author.id in patrons['silver']: - ml = 1.4 + ml = 1.25 elif ctx.author.id in patrons['gold']: - ml = 1.6 + ml = 1.35 elif ctx.author.id in patrons['diamond']: - ml = 1.7 + ml = 1.4 else: ml = 1 country = str(user['country']) - rmb = rnd(posts['resp']) + rmb = rnd(posts) + luck = user['luck'] if rmb['good'] is False: - if user['level'] == 2 or user['level'] == 3: + if luck == 2: randomChoice = random.randint(1, 10) if randomChoice == 10: - rmb = rnd(posts['resp']) - elif user['level'] == 4: + rmb = rnd(posts) + elif luck == 3: randomChoice = random.randint(1, 5) if randomChoice == 5: - rmb = rnd(posts['resp']) - elif user['level'] == 5: + rmb = rnd(posts) + elif luck == 4: randomChoice = random.randint(2, 5) if randomChoice == 5: - rmb = rnd(posts['resp']) - elif user['level'] == 6: + rmb = rnd(posts) + elif luck == 5 or luck == 6: randomChoice = random.randint(3, 5) if randomChoice == 5: - rmb = rnd(posts['resp']) + rmb = rnd(posts) + elif luck > 6: + randomChoice = random.randint(4, 5) + if randomChoice == 5: + rmb = rnd(posts) rm = rmb['text'] count = 0 - r1 = rnd(food.food[country]) - r2 = rnd(food.food[country]) - r3 = rnd(food.food[country]) - r4 = rnd(food.food[country]) + r1 = rnd(food[country]) + r2 = rnd(food[country]) + r3 = rnd(food[country]) + r4 = rnd(food[country]) rm = rm.replace("CELEB", rnd(celebrities)) if 'happy' in rm or 'refused' in rm: msg = str(rm).replace("ITEM", r1['name']) @@ -546,15 +851,15 @@ async def work(self, ctx): count = r1['price'] count *= ml count = round(count) - msg = str(rm).replace("ITEM", r1['name']).replace("COUNT", "$" + str(count)) - await self.add_money(user=ctx.author.id, count=count) + msg = str(rm).replace("ITEM", r1['name']).replace("COUNT", "<:BistroBux:1324936072760786964>" + str(count)) + #await self.add_money(user=ctx.author.id, count=count, check_tasks=True) await self.add_sold(user=ctx.author.id, sold=r1['name']) elif 'ITEM2' in rm and not 'ITEM4' in rm: count = r1['price']+r2['price']+r3['price'] count *= ml count = round(count) - msg = str(rm).replace("ITEM3", r3['name']).replace("ITEM2", r2['name']).replace("ITEM", r1['name']).replace("COUNT", "$" + str(count)) - await self.add_money(user=ctx.author.id, count=count) + msg = str(rm).replace("ITEM3", r3['name']).replace("ITEM2", r2['name']).replace("ITEM", r1['name']).replace("COUNT", "<:BistroBux:1324936072760786964>" + str(count)) + #await self.add_money(user=ctx.author.id, count=count, check_tasks=True) await self.add_sold(user=ctx.author.id, sold=r1['name']) await self.add_sold(user=ctx.author.id, sold=r2['name']) await self.add_sold(user=ctx.author.id, sold=r3['name']) @@ -562,12 +867,15 @@ async def work(self, ctx): count = r1['price']+r2['price']+r3['price']+r4['price'] count *= ml count = round(count) - msg = str(rm).replace("ITEM4", r4['name']).replace("ITEM3", r3['name']).replace("ITEM2", r2['name']).replace("ITEM", r1['name']).replace("COUNT", "$" + str(count)) - await self.add_money(user=ctx.author.id, count=count) + msg = str(rm).replace("ITEM4", r4['name']).replace("ITEM3", r3['name']).replace("ITEM2", r2['name']).replace("ITEM", r1['name']).replace("COUNT", "<:BistroBux:1324936072760786964>" + str(count)) + #await self.add_money(user=ctx.author.id, count=count, check_tasks=True) await self.add_sold(user=ctx.author.id, sold=r1['name']) await self.add_sold(user=ctx.author.id, sold=r2['name']) await self.add_sold(user=ctx.author.id, sold=r3['name']) await self.add_sold(user=ctx.author.id, sold=r4['name']) + mn_w = 0 + mn_a = 0 + mn_e = 0 if 'TIP2' in rm: tpct = random.randint(8,10) tpct *= ml @@ -575,19 +883,53 @@ async def work(self, ctx): if 'worker' in user: if user['worker']: wn = user['worker_name'] - tpct = tpct + round(tpct*user['worker'][wn][1]['tips']) - msg = msg.replace("TIP2", "$" + str(tpct)) - await self.add_money(user=ctx.author.id, count=tpct) + mn_w = tpct * user['worker'][wn][1]['tips'] + if 'apron_uses' in user: + auses = user['apron_uses'] + if auses: + mn_a = tpct * .25 + if event: + if event['type'] == 'ayce': + mn_e = tpct * .9 + tpct += round(mn_w+mn_a+mn_e) + msg = msg.replace("TIP2", "<:BistroBux:1324936072760786964>" + str(tpct)) + await self.add_money(user=ctx.author.id, count=tpct, check_tasks=True) + elif 'TIP3' in rm: + tpct = random.randint(20, 28) + tpct *= ml + tpct = round(tpct) + if 'worker' in user: + if user['worker']: + wn = user['worker_name'] + mn_w = tpct * user['worker'][wn][1]['tips'] + if 'apron_uses' in user: + auses = user['apron_uses'] + if auses: + mn_a = tpct * .25 + if event: + if event['type'] == 'ayce': + mn_e = tpct * .9 + tpct += round(mn_w+mn_a+mn_e) + msg = msg.replace("TIP3", "<:BistroBux:1324936072760786964>" + str(tpct)) + await self.add_money(user=ctx.author.id, count=tpct, check_tasks=True) elif 'TIP' in rm: - tpc = random.randint(2,4) + tpc = random.randint(2,6) tpc *= ml tpc = round(tpc) if 'worker' in user: if user['worker']: wn = user['worker_name'] - tpc = tpc + round(tpc*user['worker'][wn][1]['tips']) - msg = msg.replace("TIP", "$" + str(tpc)) - await self.add_money(user=ctx.author.id, count=tpc) + mn_w = tpc * user['worker'][wn][1]['tips'] + if 'apron_uses' in user: + auses = user['apron_uses'] + if auses: + mn_a = tpc * .25 + if event: + if event['type'] == 'ayce': + mn_e = tpc * .9 + tpc += round(mn_w+mn_a+mn_e) + msg = msg.replace("TIP", "<:BistroBux:1324936072760786964>" + str(tpc)) + await self.add_money(user=ctx.author.id, count=tpc, check_tasks=True) if r1['name'].endswith('s') or r1['name'].endswith('gna'): nn = r1['name'] else: @@ -596,75 +938,26 @@ async def work(self, ctx): else: nn = "a " + r1['name'] msg = msg.replace(r1['name'], nn) - await ctx.send(f"{ctx.author.mention}, {msg}") - if "work_hundred" in posts['tasks']: - ix = posts['tasks'].index("work_hundred") - if posts['task_list'][ix]['completed']-1 == posts['task_list'][ix]['total']: - await ctx.author.send(f"You have completed the **{posts['task_list'][ix]['description']}** task. You have been awarded **{posts['task_list'][ix]['rewards']} EXP**.") - await self.add_exp(user=ctx.author.id, count=posts['task_list'][ix]['rewards']) + wk_emb = discord.Embed(colour=0x8980d9, description=f"{ctx.author.mention}, {msg}") + if user['colour']: + wk_emb.colour = user['colour'] + if 'apron_uses' in user: + if user['apron_uses']: + uses_left = int(user['apron_uses'])-1 + await db.market.update_one({"owner": ctx.author.id}, {"$set":{"apron_uses": uses_left}}) + wk_emb.set_footer(text=f"Your Golden Apron has {uses_left} uses left.", icon_url="https://media.discordapp.net/attachments/1325282246181130330/1329660286302687257/New_Piskel.gif?ex=678b2624&is=6789d4a4&hm=6475df9cb8e5d82646fed8347eb825403e890f45061b28848b477d4e19ace3ce&=&width=1178&height=1060") + await ctx.send(embed=wk_emb) + if "work_hundred" in user['tasks']: + ix = user['tasks'].index("work_hundred") + if user['task_list'][ix]['completed']+1 == user['task_list'][ix]['total']: + await ctx.author.send(f"You have completed the **{user['task_list'][ix]['description']}** task. You have been awarded **{user['task_list'][ix]['rewards']} EXP**.") + await self.add_exp(user=ctx.author.id, count=user['task_list'][ix]['rewards'], multiplier=False) + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "work_hundred"},{"$inc": {"task_list.$.completed": 1}}) else: - new_set = str(posts['task_list']).replace('"completed:"') - db.market.update_one({"owner": ctx.author.id}, {"$set":{}}) - else: - await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `r!start`.") - @commands.command() - @commands.cooldown(1, 2, commands.BucketType.user) - async def eventinfo(self, ctx): - embed = discord.Embed(description="**EVENT - Haunted Restaurant**\n\n"\ - "Happy Halloween! Until November 1st, it'll be spooky season in Restaria!\n\n"\ - "During this event, you can earn banners and money through the `r!halloween` command!\n\n"\ - "You can earn 3 different banners... including a legendary TAKE YOUR HEART banner based off of the game series Persona 5!\n\n"\ - "You can use this command every 6 hours, that's 4 times a day! Be careful though, the prizes aren't always good!") - await ctx.send(embed=embed) - - @commands.command(aliases=['Halloweene', 'hlwe']) - @commands.cooldown(1, 21600, commands.BucketType.user) - async def halloweenez(self, ctx): - def check(m): - return m.author == ctx.message.author - #await ctx.send(f"{ctx.author.mention}, You crossed a beautiful witch on your way to work. This could be bad! Do you wanna talk to her? (yes/no)") - ans = await self.bot.wait_for('messagee', check=check, timeout=90) #erase comments & extra e next year. - if ans.content.lower() == 'yes': - rn = random.randint(1,3) - if rn == 1: - #BAD - rnc = random.randint(1,2) - if rnc == 1: - await ctx.send(f"Oh no! The witch put a late spell on you! You were 15 minutes late to work and lost 20 XP.") - await self.take_exp(user=ctx.author.id, count=20) - elif rnc == 2: - await ctx.send(f"Oh no! The witch zapped your wallet out of your hand! You lost $15!") - await self.take_money(user=ctx.author.id, count=15) - else: - #GOOD - rn2 = random.randint(1,6) - if rn2 == 1: - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": {"name": "Take your heart", "url": "https://i.ibb.co/T0qtJbt/subsource-done-button-uid-9265-BBC3-1-BC1-4-FC9-9440-85008-F9-BEF32-1602184929808-source-other-origi.jpg",'rarity': 'Legendary'}}}}) - desc = "Take your heart (Legendary) [View Banner](https://i.ibb.co/T0qtJbt/subsource-done-button-uid-9265-BBC3-1-BC1-4-FC9-9440-85008-F9-BEF32-1602184929808-source-other-origi.jpg)" - elif rn2 == 2: - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": {"name": "Trick or Treat", "url": "https://i.ibb.co/Jv6Sjwg/subsource-done-button-uid-9265-BBC3-1-BC1-4-FC9-9440-85008-F9-BEF32-1602179605747-source-other-origi.jpg",'rarity': 'Rare'}}}}) - desc = "Trick or Treat (Rare) [View Banner](https://i.ibb.co/Jv6Sjwg/subsource-done-button-uid-9265-BBC3-1-BC1-4-FC9-9440-85008-F9-BEF32-1602179605747-source-other-origi.jpg)" - elif rn2 == 3: - db.market.update_one({"owner": ctx.author.id}, {"$push": {"inventory":{"banner": {"name": "Haunted", "url": "https://i.ibb.co/SVvXT90/source-sid-9265-BBC3-1-BC1-4-FC9-9440-85008-F9-BEF32-1602005240890-subsource-done-button-uid-9265-BB.jpg",'rarity': 'Rare'}}}}) - desc = "Haunted (Rare) [View Banner](https://i.ibb.co/SVvXT90/source-sid-9265-BBC3-1-BC1-4-FC9-9440-85008-F9-BEF32-1602005240890-subsource-done-button-uid-9265-BB.jpg)" - elif rn2 == 4 or rn2 == 5 or rn2 == 6: - rnm = random.randint(15,70) - await self.add_money(user=ctx.author.id, count=rnm) - desc = f"{rnm} Cash" - embed = discord.Embed(colour=0x44165e, description=desc) - embed.set_footer(text="Come back in 6 hours!") - embed.set_thumbnail(url="http://pixelartmaker.com/art/f1394e829abdfcf.png") - await ctx.send(embed=embed, content="The witch thought you were a kind soul and gave you an enchanted chest!") - - elif ans.content.lower() == 'no': - await ctx.send("She sighed and walked away.") - self.bot.get_command("halloween").reset_cooldown(ctx) - else: - await ctx.send("That's not an option! Example: `yes`") - self.bot.get_command("halloween").reset_cooldown(ctx) - - - + await db.market.update_one({"owner": ctx.author.id, "task_list.name": "work_hundred"},{"$inc": {"task_list.$.completed": 1}}) + + else: + await ctx.send("<:RedTick:653464977788895252> You don't have a restaurant. Create one with `b.start`") @commands.command(aliases=['bugreport']) async def reportbug(self, ctx, *, topic, option=None, description=None): @@ -675,9 +968,9 @@ async def reportbug(self, ctx, *, topic, option=None, description=None): option = args[1] description = args[2] if not description: - await ctx.send(f"<:redtick:492800273211850767> {ctx.author.mention}, Incorrect Arguments. **Usage:** `r!reportbug