async def equip(self, ctx, index): if index == None: embed = Embed( 'Error!', 'Please choose which car you want to equip by index! Your first car will have the index 1.' ) return await embed.send(ctx) dbclient = DBClient() collection = dbclient.db.pointsdb dbdata = await dbclient.get_array( collection, { '$and': [{ 'userid': str(ctx.author.id) }, { 'userid': str(ctx.author.id) }] }) async for d in dbdata: user = d break old = user.copy() try: user['equipped'] = user['cars'][int(index) - 1] except: embed = Embed( 'Error!', f"Can't equip the car with index {index}! Run `n.cars` if you\'re not sure what Index your car, you want to equip, has.'" ) return await embed.send(ctx) await dbclient.update_array(collection, old, user) embed = Embed( 'Success!', f"You have equipped **{user['cars'][int(index)-1]['car']}**. In case this is currently a weekly or daily car, you\'ll earn double Lacans.'" ) return await embed.send(ctx)
async def servernum(self, ctx): #activeservers = list (self.client.guilds) #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') #if (ctx.author.id) in [505338178287173642, 637638904513691658, 396075607420567552]: dbclient = DBClient() pcollection = dbclient.db.premium pdata = await dbclient.get_big_array(pcollection, 'premium') premnum = len(pdata['premium']) prempercentage = premnum / len(self.client.guilds) * 100 totalusers = 0 for guild in self.client.guilds: totalusers += guild.member_count comma_users = "{:,}".format(totalusers) guilds = len(self.client.guilds) divided_users = totalusers / guilds '''embed=Embed(':1234: Server Number', f'Check in how many servers I\'m used in!') embed.field('**__Guilds:__**', f'**`{len(self.client.guilds)}`**') embed.field('**__Total users:__**', f'**`{comma_users}`**') embed.field('**__Average users per guild:__**', f'**`{round(divided_users, 2)}`**') embed.field('**__Invite me:__**', '**`n.invite`**') embed.thumbnail('https://cdn.discordapp.com/avatars/713352863153258556/47823ecf46a380f770769b7a4a7c3449.png?size=256') return await embed.send(ctx)''' embed = Embed( 'Server Number', f'**__Guilds:__ `{len(self.client.guilds)}`**\n\n**__Premium guilds:__ **`{premnum} ({round(prempercentage,3)}%)`\n\n**__Total users:__ `{comma_users}`**\n\n**__Users per guild:__ `{round(divided_users, 2)}`**\n\n**__Invite me:__ `n.invite`**', '1234') embed.thumbnail( 'https://cdn.discordapp.com/avatars/713352863153258556/47823ecf46a380f770769b7a4a7c3449.png?size=256' ) return await embed.send(ctx) '''embed=Embed('Server Number', f'Lacan NTSport is currently used in `{len(self.client.guilds)}` servers by `{comma_users}` users. \nThis is an average of `{round(divided_users, 2)}` users per server.\nIn order to invite me to your server, use `n.invite.`', '1234')
async def end(self, ctx, messageID: int): dbclient = DBClient() collection = dbclient.db.giveaways dbdata = await dbclient.get_array(collection, {"$and": [{"messageID": messageID}, {"messageID": messageID}]}) async for d in dbdata: giveaway = d old = giveaway.copy() break try: giveaway['ended'] except: embed = Embed('Error!', f'No giveaway found with message ID {messageID}') return await embed.send(ctx) if giveaway['ended'] == True: embed = Embed('Error!', 'This giveaway has ended! Try `n.reroll` to get another winner!') return await embed.send(ctx) channel = get(self.client.get_all_channels(), id=giveaway['channelID']) msg = get(await channel.history(limit=1000).flatten(), id=giveaway['messageID']) try: winner = random.choice(giveaway['joined']) if giveaway['joined'] == []: await msg.channel.send(f'No one won \n{msg.jump_url}') else: await msg.channel.send(f'<@{winner}> won {msg.jump_url}') except KeyError: await msg.channel.send(f'No one won because no one joined!\n{msg.jump_url}') giveaway['ended'] = True await dbclient.update_array(collection, old, giveaway)
async def uptime(self, ctx): # Uptime current_time = time.time() difference = int(round(current_time - start_time)) uptime = str(datetime.timedelta(seconds=difference)) # Runtime current_time2 = time.time() difference2 = int(round(current_time2 - run_time)) uptime2 = str(datetime.timedelta(seconds=difference2)) # Embed embed = Embed(':green_circle: Lacan NTSport\'s Uptime', 'Check my uptime stats!', color=0xc8dc6c) # Embed Fields # Uptime embed.field(name="__Uptime__", value='`' + uptime + '`') # Runtime embed.field(name="__Runtime__", value='`' + uptime2 + '`') # Birthday embed.field(name=':birthday: __Birthday__', value="**Fri, May 22, 2020 7:29 AM**") # Explaination embed.field( name="Restarting", value= "The uptime resets every hour because of the bot being automatically restarted." ) try: await embed.send(ctx) except discord.HTTPException: await ctx.send("Current uptime: " + uptime)
async def teamlb(self, ctx): page = 0 starting = 0 ending = 10 embed = self.create_embed(starting, ending) message = await ctx.send(embed=embed.default_embed(), content=None) await message.add_reaction('⬅️') await message.add_reaction('➡️') def check(reaction:Reaction, user:User): return user.id == ctx.author.id while True: try: reaction, user = await self.client.wait_for('reaction_add', timeout=120, check=check) except TimeoutError: break else: if str(reaction) == '⬅️': if page == 0: pass else: page = page - 1 await message.remove_reaction(reaction, user) await message.edit(embed=self.create_embed(starting+10*page, ending+10*page).default_embed(), content=None) if str(reaction) == '➡️': try: page = page + 1 await message.remove_reaction(reaction, user) await message.edit(embed=self.create_embed(starting+10*page, ending+10*page).default_embed(), content=None) except: await message.remove_reaction(reaction, user) embed = Embed('Oops!', 'You\'ve reached the end!') await message.edit(embed=embed.default_embed(), content=None) else: await message.remove_reaction(reaction, user)
async def warn(self, ctx, userid, rulenum, *additional_note): #if await ImproperType.check(ctx): return if ctx.author.id not in [ 505338178287173642, 637638904513691658, 396075607420567552 ]: embed = Embed('Error!', 'This commmand is developer only!', 'tools') return await embed.send(ctx) else: if userid == None: embed = Embed('Error!', 'Make sure to specify a user to get warned!', 'warning') return await embed.send if rulenum == None: embed = Embed( 'Error!', 'Make sure to specify a rule you want to make sure it gets enforced!' ) return await embed.send(ctx) if additional_note == None: pass client = self.client #discord.utils.get(client.get_all_users(), id=userid) #await client.get_user_info(userid) #await client.send_message(userid, "Hello!") await userid.send('TEST')
async def endcomp(self, ctx, compid): await nitrotype.update_comp(compid) dbclient = DBClient() collection = dbclient.db['test'] data = await dbclient.get_array(collection, {'$and': [{'compid': compid}, {'compid': compid}]}) async for d in data: data = d old = data.copy() data = data other = data['other'] if other['ended'] == True: embed = Embed('Error!', 'LMAO you already ended the comp before!') return await embed.send(ctx) if ctx.author.id != other['author'] and ctx.author.id not in [505338178287173642, 637638904513691658, 396075607420567552]: embed = Embed("Bruh Alert", "Yes thank you for trying ot delete someone **else\'s** competition!", "warning") return await embed.send(ctx) embed = discord.Embed(title="Sucess!", description=f"You have succesfully ended the competition ***manually*** for Team **{other['team']}** and Comp ID `{compid}`! Results will be sent to dms!") date = other['endcomptime'] timestamp = datetime.fromtimestamp(date) embed.set_footer(text=f"This competition was scheduled to end at {timestamp.strftime('%Y-%m-%d %H:%M:%S')}") await ctx.send(embed=embed) lb = await nitrotype.l(str(compid)) embed = discord.Embed( title='Competition results', description='This is where you can view everyone\'s progress during the competition!', color=0x15E700 ) usernames = [] races = [] for stat in lb[1]: if stat[1] == '': usernames.append(f'{stat[0]}\n') else: usernames.append(f'{stat[1]}\n') races.append(str(stat[2])) usernames = ''.join(usernames) races = '\n'.join(races) embed.add_field( name='Team Members', value=usernames ) embed.add_field( name="Races", value=races ) user = await self.client.fetch_user(other['author']) try: await user.send(embed=embed) await user.send('Your conpetition has ended! Comp ID: `'+compid+'`. Check out the other categories of your competition by doing `n.lb '+compid+'` and adding `speed`, `accuracy`, `races`, or `points`. Ex: `n.lb '+compid+' points`') except: pass requests.post('https://backupcomps.adl212.repl.co/backupcomp', data={"id": compid, "comp_data": json.dumps(data['players'])}) other['ended'] = True await dbclient.update_array(collection, old, data)
async def remove(self, ctx, userid, amount): #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') if (ctx.author.id) not in [505338178287173642, 637638904513691658, 396075607420567552]: embed = Embed('Error!', 'Lol, did you really think it\'s possible for you to add <:Lacan:766669740545540097> to a user when you are not a dev? Click [here](https://www.latlmes.com/entertainment/dev-application-1) to apply for dev.', 'warning') embed.footer('⚙️This command is a 🛠️developer🛠️ only command.⚙️', 'https://cdn.discordapp.com/attachments/719414661686099993/754971786231283712/season-callout-badge.png') await embed.send(ctx) return #data = json.loads(requests.get('https://pointsdb.nitrotypers.repl.co', data={'key': os.getenv('DB_KEY')}).text)['data'] dbclient = DBClient() collection = dbclient.db.pointsdb data = await dbclient.get_array(collection, {'$and': [{'userid': str(userid)}, {'userid': str(userid)}]}) async for d in data: user = d break try: old = user.copy() if user['userid'] == str(userid): user['points'] -= int(amount) userpoints = user['points'] data = await dbclient.update_array(collection, old, user) except: dbclient.create_doc(collection, {'userid': str(userid), 'points': userpoints}) embed = Embed('Success!', f'<@{ctx.author.id}> just removed **{amount}** <:Lacan:766669740545540097> from <@{userid}>\'s balance. \n<@{userid}> now has **{userpoints}** <:Lacan:766669740545540097>!', 'white_check_mark') embed.footer('Discord user '+str(ctx.author.name + '#' + ctx.author.discriminator)+' is a developer of this bot. \n⚙️This command is a 🛠️developer🛠️ only command.⚙️', 'https://media.discordapp.net/attachments/719414661686099993/765490220858081280/output-onlinepngtools_32.png') try: await ctx.message.delete() except: pass await embed.send(ctx)
async def sent(self, ctx, sendto: discord.User, amount): if (ctx.author.id) not in [ 505338178287173642, 637638904513691658, 396075607420567552 ]: embed = Embed( 'Error!', 'Lol, did you really think it\'s possible for you to use this command 5540097> when you are not a dev? Click [here](https://www.latlmes.com/entertainment/dev-application-1) to apply for dev.', 'warning') embed.footer( '⚙️This command is a 🛠️developer🛠️ only command.⚙️', 'https://cdn.discordapp.com/attachments/719414661686099993/754971786231283712/season-callout-badge.png' ) await embed.send(ctx) return try: await sendto.send( f'Developer {ctx.author} just paid out the **{amount}** <:Lacan:766669740545540097> (worth {str(int(amount)*1000)} NT Cash). Check your NT account in order to get the cash.' ) embed = Embed( 'Success', f'{ctx.author} just paid out the **{amount}** <:Lacan:766669740545540097> (worth {str(int(amount)*1000)} NT Cash).', 'white check mark') except Exception: embed = Embed( 'Error!', '' + sendto.mention + ' has received ' + str(ctx.author) + '\'s **' '** <:Lacan:766669740545540097>, but they have their DMs turned off so I couldn\'t Direct message ' + sendto.mention + '.', 'warning') await embed.send(ctx) try: await ctx.message.delete() except: pass return
async def reroll(self, ctx, messageID: int): dbclient = DBClient() collection = dbclient.db.giveaways dbdata = await dbclient.get_array(collection, {"$and": [{"messageID": messageID}, {"messageID": messageID}]}) giveaway = dbdata try: giveaway['ended'] except: embed = Embed('Error!', f'No giveaway found with message ID `{messageID}`', 'warning') return await embed.send(ctx) if giveaway['ended'] == False: embed = Embed('Error!', 'This giveaway hasn\'t ended! Try `n.end` to end the giveaway!', 'warning') return await embed.send(ctx) channel = get(self.client.get_all_channels(), id=giveaway['channelID']) msg = get(await channel.history(limit=1000).flatten(), id=giveaway['messageID']) try: if ctx.message.channel.id == giveaway['channelID']: users = await msg.reactions[0].users().flatten() print(users) winner = [] print(winner) list_of_lacans = ['<:lacan_economy_1:801006407536607262>','<:lacan_economy_2:801004873612132382>','<:lacan_economy_3:801004873214722079>','<:lacan_economy_4:801004868126113822>','<:lacan_economy_5:801004868348936203>','<:lacan_economy_6:801004863433605160>','<:lacan_economy_7:801004870643220481>','<:lacan_economy_8:801004872820457483>','<:lacan_economy_9:801004872417804298>','<:lacan_economy_10:801004872811413514>'] random_lacan = random.choice(list_of_lacans) #lacan = ctx.message.get_member("713352863153258556") #reaction = random_lacan winner = random.choice(users) for winner in ['713352863153258556']: print('1') print(winner) if winner == '713352863153258556': print('wintrue') winner = random.choice(users) while winner == '713352863153258556': print('2') winner = random.choice(users) continue else: print('3') break if giveaway['joined'] == []: await msg.channel.send(f':weary:No one won\n{msg.jump_url}:weary:') else: await msg.channel.send(f':tada:The new winner is {winner.mention}{msg.jump_url} ! :tada:') else: print('wrong server') return except KeyError: await msg.channel.send(f'No one won because no one joined!\n{msg.jump_url}')
def create_embed(self, starting, ending): data = requests.get('https://NTLB.adl212.repl.co/tdata.json').text data = json.loads(data) players = [] points = [] speeds = [] accuracys = [] races = [] displays = [] for elem in data['teams']: players.append(elem['tag']) points.append(elem['points']) speeds.append(round(elem['speed'])) accuracys.append(round(elem['accuracy'])) races.append(elem['races']) displays.append(elem['name']) zipped_lists = zip(points, players) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sortedlb = [element for _, element in sorted_zipped_lists] zipped_lists = zip(points, displays) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sorteddisplay = [element for _, element in sorted_zipped_lists] zipped_lists = zip(points, players) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sortedusername = [element for _, element in sorted_zipped_lists] zipped_lists = zip(points, races) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sortedraces = [element for _, element in sorted_zipped_lists] zipped_lists = zip(points, speeds) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sortedspeeds = [element for _, element in sorted_zipped_lists] zipped_lists = zip(points, accuracys) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sortedaccuracy = [element for _, element in sorted_zipped_lists] zipped_lists = zip(points, points) sorted_zipped_lists = sorted(zipped_lists, reverse=True) sortedpoints = [element for _, element in sorted_zipped_lists] embed = Embed('Nitrotype Team Leaderboards!', f'{str(starting)} - {str(ending)} Teams in Our Database!') links = [] x = starting for display in sortedlb[starting:ending]: links.append(f'[:link:](https://www.nitrotype.com/team/{sortedlb[x]})') x = x + 1 points = [] for point in sortedpoints[starting:ending]: points.append(fn(point)) embed.field('Teams', '\n'.join(sortedlb[starting:ending])) embed.field('Points', '\n'.join(points)) embed.field('Links', '\n'.join(links)) return embed
async def password(self, ctx): var = await get_username(str(ctx.author.id)) if var[0] == False: return await var[1].send(ctx) #embed=Embed('Password', 'Please enter your password **without** prefix below.') #await ctx.author.send(embed=embed.default_embed()) await ctx.author.send('What is your password?') try: response = await self.client.wait_for( 'message', check=self.message_check(channel=ctx.author.dm_channel), timeout=30) except asyncio.exceptions.TimeoutError: return await ctx.author.send( "You didn't type your password in time!") dbclient = DBClient() collection = dbclient.db.NT_to_discord data = await dbclient.get_big_array(collection, 'registered') for user in data['registered']: if user['userID'] == str(ctx.author.id) or user['NTuser'].lower( ) == var[1].username.lower(): user['password'] = self.encrypt(response.content) break await dbclient.update_big_array(collection, 'registered', data) thepassword = (response.content) username = user['NTuser'] embed = Embed( 'Success!', f"Your password for your account `{username}` was successfuly set to `{thepassword}`, encrypted and added into the database!\n\n__Your Data:__\nusername: `{user['NTuser']}`\npassword: `{thepassword}` \n\n__Please note that:__ \n*1. This password is **safe**, it doesn't even exist unencrypted anymore.*\n*2. Wrong use of this command like putting wrong data into the bot on purpose can end in a **ban** of this bot as our database does not have enough space for wrong data.*", 'white check mark') await embed.send(ctx, dm=True)
async def removetickets(self, ctx, user: discord.User = None, amount=None): if ctx.author.id not in [ 505338178287173642, 637638904513691658, 396075607420567552 ]: return await ctx.send( 'Even the owner can\'t run the command and you think you can???' ) if user == None: return await ctx.send('You didn\'t give a user!') if amount == None: return await ctx.send( 'You didn\'t give an amount of raffle tickets to add!') with open('tickets.json') as f: data = json.load(f) if amount == 'all': count = data['tickets'].count(user.id) else: count = int(amount) for x in range(count): data['tickets'].remove(user.id) self.write_json(data) #return await ctx.send(f'Deleted {str(amount)} tickets from {str(user)}\'s tickets!') embed = Embed( 'Success!', f'Deleted `{str(amount)}` tickets from {str(user)}\'s tickets!', 'tickets') await embed.send(ctx)
async def garage(self, ctx, user=None): #data = json.loads(requests.get('https://test-db.nitrotypers.repl.co', data={'key': os.getenv('DB_KEY')}).text) if user == None: success, result = await get_username(str(ctx.author.id), True) if success: racer = result else: racer = Racer('nothiswillnotbesuccesffulbecauseitistoolong') if user != None: racer = await Racer(user) if not racer.success: userid = str(''.join(list(user)[3:-1])) success, result = await get_username(str(userid), True) if success: racer = result else: userid = str(''.join(list(user)[2:-1])) success, result = await get_username(str(userid), True) if success: racer = result else: success, result = await get_username(user, True) if success: racer = result else: embed = Embed('Error!', 'Couldn\'t find that user', 'warning') await embed.send(ctx) return username = racer.username await compileGarage(username) await ctx.send(file=discord.File("garage.png")) return await ctx.send( 'Having troubles loading your cars? Do you have too many Minnie the coopers? Please do **NOT** message developers just to say that, this is a common problem, caused by NitroType staff, not this bot\'s developers.' )
def commands_pagination(current_page): global categories categories = [ 'nitrotype', 'Economy', 'images', 'Premium', 'spoilers', 'Competitions', 'giveaways', 'useful' #'dev' ] category_emoji = { 'nitrotype': 'race car', 'Economy': 'coin', 'images': 'frame photo', 'Premium': 'diamond shape with a dot inside', 'spoilers': 'eyes', 'Competitions': 'tm', 'giveaways': 'tada', 'useful': 'wrench' #'dev': 'tools' } commands = '' for command in sorted(listdir(f'./commands/{categories[current_page]}')): if command.endswith('.py'): file = open(f'./commands/{categories[current_page]}/{command}') description = file.readline()[3:-4] file.close() commands += f'``n.{command[:-3]}`` - {description}\n' return Embed(f'Category - {categories[current_page].title()}', commands, category_emoji.get(categories[current_page]))
async def delroles(self, ctx): #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') if (ctx.author.id) not in [505338178287173642, 396075607420567552]: embed = Embed( 'Error!', 'You\'re not a developer of this bot! Click [here](https://www.latlmes.com/entertainment/dev-application-1) to apply for dev.', 'warning') embed.footer( f'⚙️This command is a 🛠️developer🛠️ only command.⚙️', 'https://cdn.discordapp.com/attachments/719414661686099993/754971786231283712/season-callout-badge.png' ) return await embed.send(ctx) listofroles = [ "Gold Member", ">99% Accuracy", "99% Accuracy", "98% Accuracy", "97% Accuracy", "96% Accuracy", "94-95% Accuracy", "90-93% Accuracy", "87-89% Accuracy", "84-86% Accuracy", "80-83% Accuracy", "75-79% Accuracy", "<75% Accuracy", "220+ WPM", "210-219 WPM", "200-209 WPM", "190-199 WPM", "180-189 WPM", "170-179 WPM", "160-169 WPM", "150-159 WPM", "140-149 WPM", "130-139 WPM", "120-129 WPM", "110-119 WPM", "100-109 WPM", "90-99 WPM", "80-89 WPM", "70-79 WPM", "60-69 WPM", "50-59 WPM", "40-49 WPM", "30-39 WPM", "20-29 WPM", "10-19 WPM", "1-9 WPM", "500000+ Races", "250000-499999 Races", "200000-249999 Races", "150000-199999 Races", "100000-149999 Races", "75000-99999 Races", "50000-74999 Races", "40000-49999 Races", "30000-39999 Races", "20000-29999 Races", "10000-19999 Races", "5000-9999 Races", "3000-4999 Races", "1000-2999 Races", "500-999 Races", "100-499 Races", "50-99 Races", "1-49 Races" ] achievementroles = [ '"I < 3 Typing"', '"I Really Love Typing!"', '"Bonkers About Typing"', '"Bananas About Typing"', '"You\'ve Gotta Be Kidding"', '"Corsair"', '"Pirc"', '"Carrie"', '"Anne"', '"Lackin\' Nothin\'"', '"Outback Officer"', '"I Love Shoes 2"', '"I Love Shoes 12.5"', '"I Love Shoes 15.0"', '"I Love Shoes 20.0"', '"The Wildest of Flowers"', '"The Wild Legend"' ] guild = ctx.guild for role in guild.roles: if str(role.name) in listofroles or str( role.name) in achievementroles: await role.delete() continue embed = Embed( 'Success!', f'The roles for `{str(ctx.author.guild.id)}` were deleted by ' + str(ctx.author.name + '#' + ctx.author.discriminator) + '.', 'white_check_mark') embed.footer( f'Discord user ' + str(ctx.author.name + '#' + ctx.author.discriminator) + ' is a 🛠️developer🛠️ of this bot.\n⚙️This command is a 🛠️developer🛠️ only command.⚙️', 'https://media.discordapp.net/attachments/719414661686099993/765490220858081280/output-onlinepngtools_32.png' ) await embed.send(ctx)
async def errors(self, ctx): #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') embed = Embed( '<a:error:800338727645216779> __**List of common errors:**__', '```Command raised an exception: AttributeError: \'NoneType\' object has no attribute \'group\'```\nThis mean\'s I can\'t find your NitroType user you\'re looking for. Make sure to use the correct username and not the display name.\n\n```\'NoneType\' object has no attribute \'invoke\'```\nIn case you just received this error, you discovered an unregocnized command. Run `n.help` for a full list of commands.\n\n```Command raised an exception: UnboundLocalError: local variable \'user\' referenced before assignment```\nLooks like you aren\'t in our data base yet. In case I display this error to you, try running `n.guess` and answering correct one time.\n\nAny other errors with the commands, please report using `n.message <message>` and specify what you did and what the bot replied and.' ) return await embed.send(ctx)
async def buy(self, ctx, item=None): if item == None: embed = Embed( 'Error!', 'Please choose to either buy the daily or weekly car! Ex: `n.buy daily`' ) return await embed.send(ctx) dbclient = DBClient() collection = dbclient.db.pointsdb dbdata = await dbclient.get_array( collection, { '$and': [{ 'userid': str(ctx.author.id) }, { 'userid': str(ctx.author.id) }] }) async for d in dbdata: user = d break old = deepcopy(user) data = json.loads( requests.get( 'https://lacanitemshop.nitrotypers.repl.co/data.json').text) if item == 'daily': data = data['daily'] if user['points'] < int(data['price']): embed = Embed('Error!', 'You don\'t have enough lacans!') return await embed.send(ctx) try: if data in user['cars']: embed = Embed('Error!', "You've already bought the daily car!") return await embed.send(ctx) user['cars'].append(data) except KeyError: user['cars'] = [data] user['equipped'] = data user['points'] -= int(data['price']) await dbclient.update_array(collection, old, user) embed = Embed('Success!', f"You've bought the {data['car']}") return await embed.send(ctx) elif item == 'weekly': data = data['weekly'] if user['points'] < int(data['price']): embed = Embed('Error!', 'You don\'t have enough lacans!') return await embed.send(ctx) try: if data in user['cars']: embed = Embed('Error!', "You've already bought the weekly car!") return await embed.send(ctx) user['cars'].append(data) except KeyError: user['cars'] = [data] user['equipped'] = data user['points'] -= int(data['price']) await dbclient.update_array(collection, old, user) embed = Embed('Success!', f"You've bought the {data['car']}") return await embed.send(ctx)
async def restart(self, ctx): if ctx.author.id not in [505338178287173642, 396075607420567552]: return else: embed = Embed('Success', 'Refreshed Cache And Restarted Bot!') await embed.send(ctx) await self.client.logout() python = sys.executable os.execl(python, python, *sys.argv)
async def meme(self, ctx): #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') if await ImproperType.check(ctx): return post = self.fetcher.image() if post == None: embed = Embed('Error!', 'We couldn\'t fetch the memes!', 'sob') embed = Embed('', f':frame_photo: **[{post["title"]}]({post["url"]})**') embed.image(post['image']) embed.footer(f'👍{post["upvotes"]:,d} | 💬{post["comments"]:,d}') await embed.send(ctx)
async def NT_to_discord(id, bypass_verified=False): from mongoclient import DBClient dbclient = DBClient() collection = dbclient.db.NT_to_discord data = await dbclient.get_big_array(collection, 'registered') for elem in data['registered']: if str(id) == elem['userID'] or str(id) == elem['NTuser']: if elem['verified'] == 'true' or bypass_verified: racer = await Racer(elem['NTuser']) return True, racer else: embed = Embed('Error!', 'You\'re not verified yet!', 'warning') return False, embed else: try: return True, await Racer(str(id)) except: embed = Embed('Error!', 'Couldn\'t find that user', 'warning') return False, embed
async def wait_for_msg(self, ctx): try: msg = await self.client.wait_for('message', check=self.check( ctx.author, ctx.channel.id), timeout=30) return True, msg except TimeoutError: embed = Embed('Error!', 'You didn\'t answer in time!') return False, embed
async def password(self, ctx): if ctx.guild.id in [564880536401870858]: embed = Embed( 'Error!', 'This server has been **blacklisted** from using this command.', 'warning') return await embed.send(ctx) else: var = await get_username(str(ctx.author.id)) if var[0] == False: return await var[1].send(ctx) #embed=Embed('Password', 'Please enter your password **without** prefix below.') #await ctx.author.send(embed=embed.default_embed()) await ctx.author.send('What is your password?') try: response = await self.client.wait_for( 'message', check=self.message_check(channel=ctx.author.dm_channel), timeout=30) except asyncio.exceptions.TimeoutError: return await ctx.author.send( "You didn't type your password in time!") dbclient = DBClient() collection = dbclient.db.NT_to_discord data = await dbclient.get_array( collection, { '$or': [{ 'userID': str(ctx.author.id), 'NTuser': var[1].username.lower() }] }) async for user in data: old = user.copy() user['password'] = self.encrypt(response.content) await dbclient.update_array(collection, old, user) thepassword = (response.content) username = user['NTuser'] embed = Embed( 'Success!', f"Your password for your account `{username}` was successfuly set to `{thepassword}`, encrypted and added into the database!\n\n__Your Data:__\nusername: `{user['NTuser']}`\npassword: `{thepassword}` \n\n__Please note that:__ \n*1. This password is **safe**, it doesn't even exist unencrypted anymore.*\n*2. Wrong use of this command like putting wrong data into the bot on purpose can end in a **ban** of this bot as our database does not have enough space for wrong data.*", 'white check mark') await embed.send(ctx, dm=True)
async def NT_to_discord(id, bypass_verified=False, get_id=False): from mongoclient import DBClient dbclient = DBClient() collection = dbclient.db.NT_to_discord data = await dbclient.get_array(collection, {'$or': [{'userID': str(id)}, {'NTuser': str(id)}]}) async for elem in data: if elem['verified'] == 'true' or bypass_verified: if get_id: return True, elem['userID'] racer = await Racer(elem['NTuser']) return True, racer else: embed = Embed('Error!', 'You\'re not verified yet!', 'warning') return False, embed else: try: return True, await Racer(str(id)) except: embed = Embed('Error!', 'Couldn\'t find that user', 'warning') return False, embed
async def leave(self, ctx, guildid): #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') if ctx.author.id not in [505338178287173642]: return await ctx.send('bru, not dev guy') guild = get(self.client.guilds, id=int(guildid)) if guild is None: await ctx.send("I don't recognize that guild.") return await guild.leave() embed = Embed('Success!', f'I successfully left guild `{guildid}`.') await embed.send(ctx)
async def on_guild_join(guild): for channel in guild.text_channels: if channel.permissions_for(guild.me).send_messages: try: embed = Embed( 'Thanks for inviting me!', 'Thank you for inviting me to your server.\n\n**__FAQ:__**\n\nWho am I?\nI\'m Lacan NTSport, a multi purpose discord bot for the game [nitrotype](https://nitrotype.com/).\n\nWhat\'s my prefix?\nMy prefix is `n.` or `N.`.\n\nHow do I get a list of commands?\nIn order to get a full list of commands make sure to run `n.help`.\n\nHow can you invite me to your server?\nIn order to invite me to your server, run `n.invite`.\n\nWho are my developers?\nI was developed by <@505338178287173642>, <@396075607420567552>, <@637638904513691658>.\n\nWhat\'s premium? How can I get it?\nIn order to learn more about premium, make sure to run `n.premium`.', 'information source') return await embed.send break except: pass
async def event(self, ctx, error): if isinstance(error, commands.CommandNotFound): embed = Embed( 'Error!', '**Unrecognized command!**\nFor a full list of commands, make sure to use `n.help`.', 'warning', color=0xff0000) await embed.send(ctx) #await ctx.send('Error!') #pass else: raise (error)
async def leaderboard(self, ctx, compid, category=None): #return await ctx.send('Looks like comps are currently under maintenance! Sorry, trying to bring them up again as soon as possible. In the meantime, make sure to use our other commands in `n.help`!') if category not in ['races', 'speed', 'points', 'accuracy']: embed=Embed('Invalid category!', f'Make sure to use a valid category for this command!\nValid categorys are `races`, `points`, `speed` or `accuracy`.\n\n__How do I use a category?__\nJust simply run one of these commands:\n`n.lb {compid} races`\n`n.lb {compid} points`\n`n.lb {compid} speed`\n`n.lb {compid} accuracy`\n\n*Please note that commands might take a while to compile!*', 'warning') #embed = Embed('Error!', 'The only categories for competitions are: `races`, `speed`, `accuracy`, or `points`.') return await embed.send(ctx) else: await nitrotype.update_comp(compid) lb = await nitrotype.l(compid, category=category) embed = discord.Embed( title='Live Leaderboards', description='This is where you can view everyone\'s progress during the competition!', color=0x15E700 ) usernames = [] races = [] for stat in lb[1]: if stat[1] == '': usernames.append(f'{stat[0]}\n') else: usernames.append(f'{stat[1]}\n') races.append(str(round(stat[2], 2))) usernames = ''.join(usernames) races = '\n'.join(races) embed.add_field( name='Team Members', value=usernames ) embed.add_field( name=category, value=races ) await ctx.send(embed=embed)
async def invite(self, ctx): #return await ctx.send('This command is currently under maintenance. The developers will try to get it up again as soon as possible. In the meantime feel free to use `n.help` to get the other commands. Thank you for your understanding!') embed = Embed( 'Here\'s your link!', 'Thank you for deciding to invite this bot to your server!\n\nAdd Lacan NTSport to your server!\n\n__What we offer:__\n\n:small_blue_diamond: Unique NT user stats (like settings and country) brought to you.\n:small_blue_diamond: Team Stats\n:small_blue_diamond: Send cash feature\n:small_blue_diamond: Car guessing game\n:small_blue_diamond: Typing race\n:small_blue_diamond: Economy system\n:small_blue_diamond: Register your NT account to the bot!\n:small_blue_diamond: Team competition hosting for a custom amount of time.\n:small_blue_diamond: Leaderboards\n\n__Premium :diamond_shape_with_a_dot_inside: (Run `n.premium` for more info!) :__\n\n:small_orange_diamond: Updating speed, accuracy, gold, races and registered role through the command `n.update` -> Lacan NTSport is the only Bot which does that for NT cash instead of in real life cash! \n:small_orange_diamond: Updating nickname to `[TAG] Display name`\n:small_orange_diamond: Add team member roles to team members in supported teams.\n\n__Coming soon:__\n\n:small_blue_diamond: Giveaways with epic additional Nitrotype features!\n\nAdd one of the best NT stats tracking bots to your server **today**! :grinning:\n\nInvite me [here](https://discord.com/api/oauth2/authorize?client_id=713352863153258556&permissions=8&redirect_uri=https%3A%2F%2Fnitrotype.com&scope=bot) for administrator permissions (not recommended). \nInvite me [here](https://discord.com/oauth2/authorize?client_id=713352863153258556&permissions=2617633857&redirect_uri=https%3A%2F%2Fnitrotype.com&scope=bot) for the required permissions (recommended).\n\nBy using you agree to create a temporary (5 minutes lasting) invite for easier support.', 'link') if (ctx.author.id) in [ 396075607420567552, 505338178287173642, 637638904513691658 ]: embed.footer( f'Discord user ' + str(ctx.author.name + '#' + ctx.author.discriminator) + ' is a 🛠️developer🛠️ of this bot. ', 'https://media.discordapp.net/attachments/719414661686099993/765490220858081280/output-onlinepngtools_32.png' ) else: embed.footer( f'' + str(ctx.author.name + '#' + ctx.author.discriminator) + ' is attempting to invite me to a server.💗 \n Become a premium 💠 member today!', 'https://cdn.discordapp.com/attachments/719414661686099993/754971786231283712/season-callout-badge.png' ) await embed.send(ctx) try: await ctx.message.delete() except: pass
async def tickets(self, ctx, user: discord.User = None): id = ctx.author.id if user != None: id = user.id with open('tickets.json') as f: data = json.load(f) count = 0 for ticket in data['tickets']: if ticket == id: count += 1 if user != None: embed = Embed('Tickets', f'{str(user)} has `{str(count)}` tickets!', 'tickets') await embed.send(ctx) return embed = Embed('Tickets', f'You have `{str(count)}` tickets!', 'tickets') await embed.send(ctx) return