async def news(self, ctx): if await ImproperType.check(ctx): return page = 0 def check(reaction: Reaction, user: User): return user.id == ctx.author.id #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!') news = await News() news = news.data[page] embed = Embed( '', f':race_car: ***[{news["title"]}]({news["link"]})***\n{news["description"]}' ) embed.footer(f'{news["author"]} wrote this on {news["created"]} UTC') embed.image(news['image']) message = await ctx.send(embed=embed.default_embed(), content=None) await message.add_reaction('🔄') while True: try: reaction, user = await self.client.wait_for('reaction_add', timeout=120, check=check) except TimeoutError: await reaction.delete() break else: if str(reaction) == '🔄': news = await News() page = cycle_news(news.data, page) news = await News() news = news.data[page] embed = Embed( '', f':race_car: ***[{news["title"]}]({news["link"]})***\n{news["description"]}' ) embed.footer( f'{news["author"]} wrote this on {news["created"]} UTC' ) embed.image(news['image']) await message.remove_reaction(reaction, user) await message.edit(embed=embed.default_embed()) else: await message.remove_reaction(reaction, user)
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 cars(self, ctx, user=None): 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: data = d break page = 0 def check(reaction: Reaction, user: User): return user.id == ctx.author.id embed = Embed('Cars You Own!', 'The cars you bought with lacans!') embed.field('Equipped Car!', data['equipped']['car']) embed.image('https://www.nitrotype.com/cars/' + data['equipped']['img'].replace('small', 'large')) embed.footer('You can buy cars or equip cars using n.buy or n.equip!') message = await ctx.send(embed=embed.default_embed()) await message.add_reaction('🔄') while True: try: reaction, user = await self.client.wait_for('reaction_add', timeout=120, check=check) except TimeoutError: break embed = Embed('Cars You Own!', 'The cars you bought with lacans!') embed.field(f'Car Index {page+1}', data["cars"][page]["car"]) embed.image( f"https://www.nitrotype.com/cars/{data['cars'][page]['img'].replace('small', 'large').strip()}" ) await message.remove_reaction(reaction, user) await message.edit(embed=embed.default_embed()) page += 1 if page >= len(data['cars']): page = 0
async def event(self, member): dbclient = DBClient() collection = dbclient.db.servers server = await dbclient.get_array(collection, {'serverID': member.guild.id}) try: async for x in server: data = x break except: return try: print(data) channel_id = data['channel_id'] channel = discord.utils.get(self.client.get_all_channels(), id=channel_id) message = data['message'] except: return try: racer = await NT_to_discord(member.id) racer = racer[1] username = racer.username speed = racer.speed_role accuracy = racer.accuracy_role races = racer.race_role #except Exception as e: #print(e) except: embed=Embed('Welcome to the server! :wave:', f'{member.mention} unfortunately isn\'t associated to a Nitro Type account yet. Please type `n.register` to start the verification process.') return await channel.send(embed=embed.default_embed()) message = message.replace('{{user.mention}}', member.mention) message = message.replace('{{user.id}}', str(member.id)) message = message.replace('{{user.racer.username}}', username) message = message.replace('{{user.racer.speed}}', speed) message = message.replace('{{user.racer.accuracy}}', accuracy) message = message.replace('{{user.racer.races}}', races) embed=Embed(f'Welcome to the server! :wave:', message) try: await channel.send(embed=embed.default_embed()) except: embed=Embed('Welcome to the server! :wave:', f'{member.mention} unfortunately isn\'t associated to a Nitro Type account yet. Please type `n.register` to start the verification process.') return await channel.send(embed=embed.default_embed())
async def buypremium(self, ctx): dbclient = DBClient() collection = dbclient.db.premium data = await dbclient.get_big_array(collection, 'premium') for x in data['premium']: if x['serverID'] == str(ctx.author.guild.id): embed = Embed('Error!', 'This server is already premium!', 'warning') return await embed.send(ctx) else: del collection del data collection = dbclient.db.pointsdb data = await dbclient.get_array( collection, { '$and': [{ 'userid': str(ctx.author.id) }, { 'userid': str(ctx.author.id) }] }) async for d in data: data = d old = data.copy() break try: points = data['points'] except: embed = Embed('Error!', 'The user doesn\'t have any lacans!') return await embed.send(ctx) data['points'] = int(points) - 3000 if data['points'] < 0: embed = Embed('Error!', 'You do not have 3000 lacans!', 'rofl') return await embed.send(ctx) await dbclient.update_array(collection, old, data) embed = Embed( 'Success!', 'You have bought premium for this server, pending dev verification. \n\n*Please wait for a developer to accept your server for premium. If you get rejected, your lacans will be refunded.*', 'white check mark') await embed.send(ctx) channel = discord.utils.get(self.client.get_all_channels(), id=810296381779476510) embed = Embed( 'Someone Wants Premium!', 'Click :ballot_box_with_check: to accept or :x: to deny.') embed.field('Guild ID', f'{str(ctx.guild.id)}') embed.field('Guild Name', f'{str(ctx.guild)}') embed.field('Buyer ID', f'{str(ctx.author.id)}') embed.field('Buyer Name', str(ctx.author)) msg = await channel.send(embed=embed.default_embed()) await msg.add_reaction('☑️') await msg.add_reaction('❌')
async def dm(self, ctx, user: discord.Member = None, *, message = None): #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!') developers = [505338178287173642, 396075607420567552] if ctx.author.id in developers: if user == None: return await ctx.send('Please specify a user you\'re sending your message to.') else: pass if message == None: return await ctx.send('Please specify a message you want to send.') else: embed=Embed('New Direct Message', 'speech_left') embed.field('Author:', f'Message sent by {ctx.author}') embed.field('Message:', f'Following message was sent: {message}') return await user.send(embed=Embed.default_embed()) else: return await ctx.send('You do not have perms, dude.')
async def event(self, payload): if payload.user_id == 713352863153258556: return dbclient = DBClient() collection = dbclient.db.giveaways dbdata = await dbclient.get_array(collection, {'$and': [{'messageID': payload.message_id}, {'messageID': payload.message_id}]}) async for d in dbdata: user = d break try: old = copy.deepcopy(user) req_passed = await check_perms(payload.user_id, user['requirements']) if not req_passed: channel = discord.utils.get(self.client.get_all_channels(), id=int(payload.channel_id)) msg = discord.utils.get(await channel.history().flatten(), id=int(payload.message_id)) else: return await msg.remove_reaction(payload.emoji, payload.member) if payload.user_id in user['joined']: return user['joined'].append(payload.user_id) embed = Embed(':partying_face: You entered the giveaway! :partying_face:', 'You successfully entered the giveaway!') embed.field('Link', f'[Giveaway Link](https://discord.com/channels/{str(payload.guild_id)}/{str(payload.channel_id)}/{str(payload.message_id)}') await payload.member.send(embed=embed.default_embed()) return await dbclient.update_array(collection, old, user) except: try: req_passed = await check_perms(payload.user_id, user['requirements']) if req_passed: channel = discord.utils.get(self.client.get_all_channels(), id=int(payload.channel_id)) msg = discord.utils.get(await channel.history().flatten(), id=int(payload.message_id)) user['joined'] = [payload.user_id] embed = Embed(':partying_face: Entry approved! :partying_face:', 'You successfully entered the giveaway!') embed.field(':link: Link', f'**[Giveaway Link](https://discord.com/channels/{str(payload.guild_id)}/{str(payload.channel_id)}/{str(payload.message_id)})**') embed.field(':tools: Support Server', 'Join the official **[Support Server](https://discord.gg/Wj96Ehg)**!') embed.field(':arrow_up: Vote', 'Vote for me **[here](https://top.gg/bot/713352863153258556)**.') embed.field(':link: Invite', 'Invite me through **[this](https://discord.com/oauth2/authorize?client_id=713352863153258556&permissions=2617633857&redirect_uri=https%3A%2F%2Fnitrotype.com&scope=bot)** link.') await payload.member.send(embed=embed.default_embed()) return await dbclient.update_array(collection, old, user) else: await msg.remove_reaction(payload.emoji, payload.member) except Exception as e: pass if int(payload.channel_id) == 810296381779476510: emoji = payload.emoji else: return if str(emoji) == '☑️': accepted = True else: accepted = False channel = discord.utils.get(self.client.get_all_channels(), id=int(payload.channel_id)) msg = discord.utils.get(await channel.history().flatten(), id=int(payload.message_id)) data = [] for field in (msg.embeds[0].fields): data.append((field.name, field.value)) data = dict(data) dbclient = DBClient() collection = dbclient.db.premium dbdata = await dbclient.get_big_array(collection, 'premium') if {"serverID": str(data['Guild ID'])} in dbdata['premium']: return if accepted == False: user = await self.client.fetch_user(int(data['Buyer ID'])) embed = Embed(':weary: Declined!', 'Your server\'s premium application has been denied. It will not be given premium. You have been refunded the Lacans.') collection = dbclient.db.pointsdb data = await dbclient.get_array(collection, {'$and': [{'userid': str(data['Buyer ID'])}, {'userid': str(data['Buyer ID'])}]}) async for d in data: data = d old = copy.deepcopy(data) break points = data['points'] data['points'] = int(points) + 3000 await dbclient.update_array(collection, old, data) await msg.delete() return await user.send(embed=embed.default_embed()) else: listofroles = [">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"] guild = discord.utils.get(self.client.guilds, id=int(data['Guild ID'])) dbdata['premium'].append({'serverID': str(guild.id)}) await dbclient.update_big_array(collection, 'premium', dbdata) await guild.create_role(name="Gold Member", colour=discord.Colour(0xFFFF00)) for role in listofroles: await guild.create_role(name=role) user = await self.client.fetch_user(int(data['Buyer ID'])) embed = Embed('Success!', 'Your server has been given premium!') await msg.delete() channel1 = discord.utils.get(self.client.get_all_channels(), id=812375645828153385) channel2 = discord.utils.get(self.client.get_all_channels(), id=812268302117634078) 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) #data['Buyer ID'] is the buyer id/ctx.author.id #data['Buyer Name'] is the buyer name/str(ctx.author) #data['Guild ID'] is the guild id/ctx.guild.id #data['Guild Name'] is the guild name/str(ctx.guild) author = data['Buyer ID'] guildid = data['Guild ID'] guildname = data['Guild Name'] amount = 3000 embed=Embed(':diamond_shape_with_a_dot_inside: New premium guild!', f'Lacan NTSport just sold a new premium server for `{amount}` {random_lacan}!') embed.field('Buyer ID', f'`{author}`') embed.field('Buyer Mention', f'<@{author}>') embed.field('Guild ID', f'`{guildid}`') embed.field('Guild Name', f'**{guildname}**') await channel1.send(embed=embed.default_embed()) await channel2.send(embed=embed.default_embed())
async def checkbot(self, ctx, username): # return await ctx.send('**Your** security is important for **us**! Because of security reasons, this command has been taken down and will be back soon. Thanks for your understanding.') racer = await Racer(username) if not racer.success: return Embed('Error!', 'That account does not exist!') prediction = await check(username) print(prediction) pred = prediction['botornot'][1] botornot_value = prediction['botornot'][0] accuracy = sum(prediction['accuracy']) / 2 df = pandas.read_csv("data.csv") features = ['avgSpeed', 'highSpeed', 'racesTotal', 'highestSession'] avgdivhigh = [] racesTotal = list(df['racesTotal']) highest = [] highest_int = 0 for x in df['racesTotal']: avgSpeed = int( list(df['avgSpeed'])[list(df['racesTotal']).index(x)]) highSpeed = int( list(df['highSpeed'])[list(df['racesTotal']).index(x)]) highestSession = int( list(df['highestSession'])[list(df['racesTotal']).index(x)]) if list(df['Go'])[list(df['racesTotal']).index(x)] == 1: del racesTotal[list(racesTotal).index(x)] continue avgdivhigh.append( (int(x) - highestSession) * (highSpeed - avgSpeed)) plt.scatter(racesTotal, avgdivhigh, color='blue') ''' slope, intercept, r, p, std_err = stats.linregress(racesTotal, avgdivhigh) def myfunc(x): return slope * x + intercept #print(myfunc(234061)) mymodel = list(map(myfunc, racesTotal)) ''' mymodel = numpy.poly1d(numpy.polyfit(racesTotal, avgdivhigh, 3)) myline = numpy.linspace(1, 700000, 700000) plt.plot(myline, mymodel(myline), color='blue') plt.xlabel('Races') plt.ylabel('Formula') plt.scatter([int(racer.races.replace(',', ''))], [(int(racer.races.replace(',', '')) - int(racer.newdata['longestSession'])) * (int(racer.wpm_high.replace(',', '')) - int(racer.wpm_average.replace(',', '')))], color='red') plt.savefig('graph.png') plt.cla() embed = Embed('Botting Or Not?', 'Analysis of **' + username + '**') if racer.success == False: embed.field('Error!', 'I could not find that account!') else: embed.field('Bot Or Not', '__BOT__' if botornot_value == 1 else '__LEGIT__') embed.field('Chance Of Being A Bot', str(round(pred * 100, 2)) + '%') embed.field('Accuracy', '`' + str(accuracy) + '`%') file = discord.File("graph.png", filename="graph.png") embed.image(url="attachment://graph.png") await ctx.send(file=file, embed=embed.default_embed())
async def on_message(message): if message.author.bot == True and ( message.content.startswith('n.') or message.content.startswith('N.') or message.content.startswith('<@!713352863153258556>') or message.content.startswith('<@713352863153258556>')): print('Stop using bots on user accounts!') embed = Embed( '<:bruh:834049885414227998> Bruh', 'What are you thinking? If you want to use me, get on a user account. You can\'t use commands through bots. <a:keka:800338138802946098>' ) ctx = await client.get_context(message) return await embed.send(ctx) else: if message.content == "<@!713352863153258556>" or message.content == "<@713352863153258556>": ctx = await client.get_context(message) #return #embed=Embed('Lacan NTSport', 'Test') #await embed.send #return embed = Embed( 'Lacan NTSport', '**__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(ctx, dm=False) #return await message.channel.send('<@505338178287173642> **YOU F*****G BASTARD**') if message.author.id == 713352863153258556: return if "780980594892341288" in message.content.split(' '): return '''#Permanent Bans: ctx = await client.get_context(message) if message.author.id == permbanned[0] and ( message.content.startswith('n.') or message.content.startswith('N.') or message.content.startswith('<@!713352863153258556>') or message.content.startswith('<@713352863153258556>')) or int(message.guild.id) == 799733929481207858: embed=Embed(':hammer_pick: Banned :hammer_pick:', f'<@{message.author.id}> has been banned from the bot.\n\n__**Duration:**__ **`Permanent`**\n\n__**Reason:**__ ```Insanely high amounts of activity.```\n\n*If you believe this ban is an error, contact <@505338178287173642> for more information.*') return await embed.send(ctx, dm=False) return''' ''' if message.author.id != 396075607420567552: return ''' try: if int(message.author.id) in banned and ( message.content.startswith('n.') or message.content.startswith('N.') or message.content.startswith('<@!713352863153258556>') or message.content.startswith('<@713352863153258556>') ) or int(message.guild.id) == 799733929481207858: ctx = await client.get_context(message) embed = Embed( 'Ooops!', 'Looks like you are **BANNED** from the bot!\n\n__Reason:__ `Sending bot commands too fast.`\n\n*You will be unbanned upon the bot restart.* \n*If you believe this is an error, make sure to contact one of the developers (`n.info`).*', 'tools') return await embed.send(ctx, dm=False) #return await message.channel.send('Your banned from the bot!') if message.author.id == 780980594892341288 and ( message.content.startswith('n.') or message.content.startswith('N.') or message.content.startswith('<@!713352863153258556>') or message.content.startswith('<@713352863153258556>')): return await message.channel.send( 'Happy living as a weasel. -the devs') else: if (message.content.startswith('n.') or message.content.startswith('N.') or message.content.startswith('<@!713352863153258556>') or message.content.startswith('<@713352863153258556>')): if message.author.id not in [713352863153258556]: timestamps.append(round(time.time())) authors.append(message.author.id) indices = sorted([ i for i, x in enumerate(authors) if x == message.author.id ]) if len(indices) <= 10: pass else: inbetweens = [] timestamp1 = 0 timestamp2 = 0 for i in indices: if timestamp1 == 0: timestamp1 = timestamps[i] continue if timestamp2 == 0: timestamp2 = timestamps[i] else: inbetweens.append(timestamp2 - timestamp1) timestamp1 = 0 timestamp2 = 0 if mean(inbetweens) <= 2: channel = discord.utils.get( client.get_all_channels(), id=807659844089806898) await channel.send('<@&808658319648227328>') embed = Embed(':tools: Banned Member!', str(message.author)) embed.field('Author ID', f' `{str(message.author.id)}`') embed.field('Author Guild', f'**{str(message.guild)}**') embed.field('Author Guild ID', f'`{str(message.guild.id)}`') await channel.send(embed=embed.default_embed()) banned.append(message.author.id) #check for botters #print(f"{message.content} | {message.author.id} | {str(message.author)} | {message.guild.id} | {str(message.guild)}") async with message.channel.typing(): await asyncio.sleep(random.uniform(0.05, 0.1)) #return await client.process_commands(message) try: ctx = await client.get_context(message) await ctx.command.invoke(ctx) except Exception as e: raise e shouldraise = True if isinstance(e, AttributeError): embed = Embed( '<a:error:800338727645216779> Error!', '**Unrecognized command!**\nFor a full list of commands, make sure to use `n.help`.', color=0xff0000) await embed.send(ctx) shouldraise = False else: embed = Embed( '<a:error:800338727645216779> Error!', f'```{e}```\nThe developers have received your error message.\nUse `n.errors` for an explaination on your error.' ) await embed.send(ctx) channel = discord.utils.get(client.get_all_channels(), id=787018607481192479) channel2 = discord.utils.get(client.get_all_channels(), id=803938544175284244) '''embed = Embed('__**Command Log**__', str(message.author)) embed.field('__Command__', f'`n.{("".join(list(message.content)[2:]))}`') embed.field('__User ID__', f'`{str(message.author.id)}`') embed.field('__Guild ID__', f'`{str(message.guild.id)}`') embed.field('__Guild Name__',f' **{str(message.guild.name)}**') embed.field('__Channel ID__', f'`{str(ctx.message.channel.id)}`') try: try: invitelink = await ctx.channel.create_invite(max_age=300, max_uses=100, unique='False', reason='Better support features - instant developer notification, easier to help people. Don\'t want this? Remove my permission to create invites, but then don\'t expect immediate support.') except: invitelink = await ctx.channel.create_invite(max_age=300, max_uses=100, unique='True', reason='Better support features - instant developer notification, easier to help people. Don\'t want this? Remove my permission to create invites, but then don\'t expect immediate support.') embed.field('__Invite__', f'{invitelink}') except: pass embed.field('__Error__', f'```{e}```') await channel.send(embed=embed.default_embed()) await channel2.send(embed=embed.default_embed())''' if shouldraise: raise e return '''channel = discord.utils.get(client.get_all_channels(), id=787018607481192479) channel2 = discord.utils.get(client.get_all_channels(), id = 803938544175284244) embed = Embed('__**Command Log**__', str(message.author), color=0x2ecc71) embed.field('__Command__', f'`n.{("".join(list(message.content)[2:]))}`') embed.field('__User ID__', f'`{str(message.author.id)}`') embed.field('__Guild ID__', f'`{str(message.guild.id)}`') embed.field('__Guild Name__',f' **{str(message.guild.name)}**') try: try: invitelink = await ctx.channel.create_invite(max_age=300, max_uses=100, unique='False', reason='Better support features - instant developer notification, easier to help people. Don\'t want this? Remove my permission to create invites, but then don\'t expect immediate support.') except: invitelink = await ctx.channel.create_invite(max_age=300, max_uses=100, unique='True', reason='Better support features - instant developer notification, easier to help people. Don\'t want this? Remove my permission to create invites, but then don\'t expect immediate support.') embed.field('__Invite__', f'{invitelink}') except: pass embed.field('__Channel ID__', f'`{str(ctx.message.channel.id)}`') await channel.send(embed=embed.default_embed()) await channel2.send(embed=embed.default_embed())''' except: return ctx = await client.get_context(message) await ctx.command.invoke(ctx)
async def check_giveaways(self): #print('running check gw script') dbclient = DBClient() collection = dbclient.db.giveaways documents = collection.find({}) async for data in documents: #print('in documents') #print(int(time.time())) #print(data['endtime']) #print(data['ended']) if int(time.time()) >= data['endtime'] and data['ended'] == False: print('big enough') old = copy.deepcopy(data) channel = get(self.client.get_all_channels(), id=data['channelID']) print('got the channel') try: msg = get(await channel.history(limit=1000).flatten(), id=data['messageID']) print('g1') except: data['ended'] = True await dbclient.update_array(collection, old, data) print('g2') amt_winners = data['winners'] if msg == None: data['ended'] = True await dbclient.update_array(collection, old, data) print('g3') continue prize = data['gwcontent'] try: try: winners = '' winners = random.choices(data['joined'], k=int(amt_winners)) except IndexError: try: winners = [random.choice(data['joined'])] except IndexError: await msg.channel.send( f'No one won \n{msg.jump_url}') mentions = '' for winner in winners: mentions += f'<@{winner}> ' print({winner}) print({mentions}) embed = msg.embeds[0] embed.description += f'\n\nWinners: {mentions}' embed.color = 0xFF0000 await msg.edit(embed=embed) if data['joined'] == []: await msg.channel.send( f'I couldn\'t determine a winner for {msg.jump_url}' ) else: await msg.channel.send( f'{mentions} won the giveaway for **{prize}**! {msg.jump_url}' ) embed = Embed('🎉 Congratulations! 🎉', f'You won **{prize}**!') embed.field('🔗 Link', f'**[Giveaway Link]({msg.jump_url})**') embed.field( '🛠️ Support Server', 'Join the official **[Support Server](https://discord.gg/Wj96Ehg)**!' ) embed.field( '⬆️ Vote', 'Vote for me **[here](https://top.gg/bot/713352863153258556)**.' ) embed.field( '🔗 Invite', 'Invite me through **[this](https://discord.com/oauth2/authorize?client_id=713352863153258556&permissions=2617633857&redirect_uri=https%3A%2F%2Fnitrotype.com&scope=bot)** link.' ) for winner in winners: try: user = await self.client.fetch_user(int(winner) ) await user.send(embed=embed.default_embed()) except: pass except Exception as e: await msg.channel.send( f'I couldn\'t determine a winner for{msg.jump_url}.') data['ended'] = True await dbclient.update_array(collection, old, data) else: continue
async def typerace(self, ctx): 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) channels = self.client.get_all_channels() channel = get(channels, id=803879362226946088) green =0x40AC7B red = 0xE84444 orange = 0xF09F19 with open('text.txt') as f: sentences = f.readlines() t = random.choice(sentences).strip() start = random.randint(1, 5) end = random.randint(start+4, start+8) t = ' '.join(((base64.standard_b64decode(t)).decode().split())[start:end]) await self.create_image(t) embed = Embed("Type The Text!", "Type faster for bonus "+random_lacan+"!", "keyboard") #creates embed file = discord.File("text.png", filename="text.png") embed.image(url="attachment://text.png") await ctx.send(file=file, embed=embed.default_embed()) def check(message: discord.Message): return message.author.id == ctx.author.id start = round(time.time()) try: response = await self.client.wait_for('message', timeout=15, check=check) except asyncio.exceptions.TimeoutError: embed = Embed('<a:error:800338727645216779> Error!', 'You ran out of time because you took longer than `15` seconds to respond!') return await embed.send(ctx) 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) channels = self.client.get_all_channels() channel = get(channels, id=803879362226946088) green =0x40AC7B red = 0xE84444 orange = 0xF09F19 if ctx.author.id not in [505338178287173642, 637638904513691658, 396075607420567552]: cooldown_add(str(ctx.author)) if response.content == t: data = json.loads(requests.get('https://lacanitemshop.nitrotypers.repl.co/data.json').text) shopcars = [data['daily']['img'], data['weekly']['img']] dbclient = DBClient() collection = dbclient.db.pointsdb data = await dbclient.get_array(collection, {'$and': [{'userid': str(ctx.author.id)}, {'userid': str(ctx.author.id)}]}) async for d in data: user = d break try: old = copy.deepcopy(user) for car in user['cars']: if user['equipped']['img'] in shopcars: carbonus = True break else: carbonus = False except: carbonus = False end = round(time.time()) total = end-start bonus = round(5/total) if carbonus: default = 3 earned = (default+bonus)*2 else: default = 3 earned = default+bonus embed = Embed('<a:Check:797009550003666955> Congrats!', f'You Earned {random_lacan}!') embed.field('Default', str(default)) embed.field('Bonus', str(bonus)) embed.field('Total', str(earned)) if carbonus: embed.field('Multiplier', 'X2') embed.footer('You earned double lacans by equipping the daily or weekly car!') await embed.send(ctx) try: if user['userid'] == str(ctx.author.id): user['points'] += earned await dbclient.update_array(collection, old, user) except UnboundLocalError: await dbclient.create_doc(collection, {'userid': str(ctx.author.id), 'points': earned}) else: embed = Embed('<a:false:800330847865143327> Oops!', 'You messed up sadly... and lost **3** '+random_lacan+'.') await embed.send(ctx) #Loose lacans dbclient = DBClient() collection = dbclient.db.pointsdb data = await dbclient.get_array(collection, {'$and': [{'userid': str(ctx.author.id)}, {'userid': str(ctx.author.id)}]}) lost = -3 async for d in data: user = d break try: old = user.copy() if user['userid'] == str(ctx.author.id): user['points'] += lost await dbclient.update_array(collection, old, user) else: await dbclient.create_doc(collection, {'userid': str(ctx.author.id), 'points': lost}) except UnboundLocalError: await dbclient.create_doc(collection, {'userid': str(ctx.author.id), 'points': lost}) return
async def checkbot(self, ctx, username): # return await ctx.send('**Your** security is important for **us**! Because of security reasons, this command has been taken down and will be back soon. Thanks for your understanding.') racer = await Racer(username) async with aiohttp.ClientSession() as s: botornot = await self.fetch( 'https://Lacan-Checkbot.try2win4code.repl.co', s, data={'username': username}) print(botornot) csvdata = await self.fetch( 'https://Lacan-Checkbot.try2win4code.repl.co/data.csv', s) with open('data.csv', 'w') as f: f.write(csvdata) df = pandas.read_csv("data.csv") features = ['avgSpeed', 'highSpeed', 'racesTotal', 'highestSession'] avgdivhigh = [] racesTotal = list(df['racesTotal']) highest = [] highest_int = 0 for x in df['racesTotal']: avgSpeed = int( list(df['avgSpeed'])[list(df['racesTotal']).index(x)]) highSpeed = int( list(df['highSpeed'])[list(df['racesTotal']).index(x)]) highestSession = int( list(df['highestSession'])[list(df['racesTotal']).index(x)]) if list(df['Go'])[list(df['racesTotal']).index(x)] == 1: del racesTotal[list(racesTotal).index(x)] continue avgdivhigh.append( (int(x) - highestSession) * (highSpeed - avgSpeed)) plt.scatter(racesTotal, avgdivhigh, color='blue') ''' slope, intercept, r, p, std_err = stats.linregress(racesTotal, avgdivhigh) def myfunc(x): return slope * x + intercept #print(myfunc(234061)) mymodel = list(map(myfunc, racesTotal)) ''' mymodel = numpy.poly1d(numpy.polyfit(racesTotal, avgdivhigh, 3)) myline = numpy.linspace(1, 700000, 700000) plt.plot(myline, mymodel(myline), color='blue') plt.xlabel('Races') plt.ylabel('Formula') plt.scatter([int(racer.races.replace(',', ''))], [(int(racer.races.replace(',', '')) - int(racer.newdata['longestSession'])) * (int(racer.wpm_high.replace(',', '')) - int(racer.wpm_average.replace(',', '')))], color='red') plt.savefig('graph.png') plt.cla() embed = Embed('Botting Or Not?', 'Analysis of **' + username + '**') if botornot['botornot'] == 'error': embed.field('Error!', 'I could not find that account!') else: embed.field( 'Bot Or Not', '__BOT__' if botornot['botornot'][0] == 1 else '__LEGIT__') embed.field('Chance Of Being A Bot', str(botornot['botornot'][1] * 100) + '%') embed.field( 'Accuracy', '`' + str( ((botornot['accuracy'][0] * 100) + (botornot['accuracy'][1] * 100)) / 2) + '`%') file = discord.File("graph.png", filename="graph.png") embed.image(url="attachment://graph.png") await ctx.send(file=file, embed=embed.default_embed())
async def giveaway(self, ctx): role1 = get(ctx.message.guild.roles, name='Giveaways') for role in ctx.author.roles: if role.name.lower() == "giveaways": has_perm = True break #else: #has_perm = False #if has_perm == False: #pass if ctx.author.guild_permissions.manage_guild: has_perm = True elif ctx.author.guild_permissions.administrator: has_perm = True elif ctx.author.id in [505338178287173642]: has_perm = True elif role.name.lower() == "giveaways": has_perm = True else: has_perm = False if has_perm == False: pass print(has_perm) if has_perm == False: embed = Embed( ':warning: Error!', 'Seems like you don\'t have the permission to use this command.\n\nThis command requires a role called `Giveaways`.' ) return await embed.send(ctx) embed = Embed( ':partying_face: Create A Giveaway: Step 1 - Channel :partying_face:', 'In what channel do you want the giveaway to be hosted?', color=0x00FF00) embed.field( '__Instructions:__', 'Type in a channel ID or mention of the channel where the giveaway should be hosted!\n\n*Example response: **#giveaways***' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] if ''.join(list(msg.content)[:2]) == "<#": channel = ''.join(list(msg.content)[2:-1]) elif list(msg.content)[:2] == "<!#": channel = ''.join(list(msg.content)[3:-1]) elif msg.content.isdigit(): channel = msg.content else: embed = Embed(':warning: Error!', 'You didn\'t give a valid channel ID or mention!') return await embed.send(ctx) embed = Embed( ':partying_face: Create A Giveaway: Step 2 - Duration :partying_face:', 'How Long Is Your Giveaway going to last?', color=0x00FF00) embed.field( '__Instructions:__', 'Use `s` for seconds, `m` for minutes, `h` for hours and `d` for days.\n\n*Example response: **1d***' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] msg = msg.content if len(msg.split('s')) == 2: msg = msg.split('s') if not msg[0].isdigit(): embed = Embed(':warning: Error!', 'Invalid amount of time!') return await embed.send(ctx) gwtime = ('seconds', int(msg[0])) elif len(msg.split('m')) == 2: msg = msg.split('m') if not msg[0].isdigit(): embed = Embed(':warning: Error!', 'Invalid amount of time!') return await embed.send(ctx) gwtime = ('minutes', int(msg[0])) elif len(msg.split('h')) == 2: msg = msg.split('h') if not msg[0].isdigit(): embed = Embed(':warning: Error!', 'Invalid amount of time!') return await embed.send(ctx) gwtime = ('hours', int(msg[0])) elif len(msg.split('d')) == 2: msg = msg.split('d') if not msg[0].isdigit(): embed = Embed(':warning: Error!', 'Invalid amount of time!') return await embed.send(ctx) gwtime = ('days', int(msg[0])) else: embed = Embed(':warning: Error!', 'You didn\'t give a valid amount of time!') return await embed.send(ctx) embed = Embed( ':partying_face: Create A Giveaway: Step 3 - Winners :partying_face:', 'How Many Winners should this giveaway have?', color=0x00FF00) embed.field( '__Instructions:__', 'Reply with the amount of winners you wish this giveaway to have.\n\n*Example response: **1***' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] msg = msg.content if msg.isdigit: winners = msg else: embed = Embed(':warning: Error!', 'You didn\'t give a valid number of winners!') return await embed.send(ctx) embed = Embed( ':partying_face: Create A Giveaway: Step 4 - Prize :partying_face:', 'What should the prize of this giveaway be?', color=0x00FF00) embed.field( '__Instructions:__', 'What are you giving away?\n\n*Example response: **100K NT cash ~courtesy of ⚡Try2Win4Glory⚡***' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] prize = msg.content embed = Embed( ':partying_face: Create A Giveaway: Step 5 - Requirements :partying_face:', 'Should this giveaway have requirements?', color=0x00FF00) embed.field( '__Instructions:__', 'Reply with `y` if you want to include requirements, reply with `n` if you\'d like to start the giveaway without requirements\n\n*Example response: **y***' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] requirements = {} if msg.content.lower() in ['y', 'n']: if msg.content.lower() in ['y']: while True: embed = Embed( ':partying_face: Create A Giveaway: Step 5 - Requirements :partying_face:', 'What type of requirement do you want?', color=0x00FF00) embed.field( '__Instructions:__', 'You can have `team` and `membership` requirements currently! Type one of them in! Type `none` to create the giveaway!' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] if msg.content.lower() == "team": embed = Embed( ':partying_face: Create A Giveaway: Step 5 - Requirements :partying_face:', 'What team does the user have to be in?', color=0x00FF00) embed.field( '__Instructions:__', 'Give a valid team name or team tag here!') await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] team = await Team(msg.content) if team.data == {}: embed = Embed('Invalid Team!', 'Oops you messed up!') await embed.send(ctx) continue else: requirements.update({"team": msg.content}) continue if msg.content.lower() == "membership": embed = Embed( ':partying_face: Create A Giveaway: Step 5 - Requirements :partying_face:', 'What type of membership does a person have to have?', color=0x00FF00) embed.field( '__Instructions:__', 'Type `gold` or `basic`, depending on the membership the users needs to have.' ) await embed.send(ctx) msg = await self.wait_for_msg(ctx) if msg[0] == False: return msg[1].send(ctx) else: msg = msg[1] if msg.content.lower() == "gold": requirements.update({"membership": "gold"}) if msg.content.lower() == "basic": requirements.update({"membership": "basic"}) else: embed = Embed('Invalid Membership', 'Oops you messed up!') await embed.send(ctx) continue if msg.content.lower() == "none": break else: if msg.content in ['n']: pass embed = Embed( ':white_check_mark: Success!', f'You\'ve created a giveaway that will be hosted in channel <#{str(channel)}>, lasts **{gwtime[1]}** **{gwtime[0]}**, has **{winners}** winners, and you\'re giving away **{prize}**', color=0x00FF00) await embed.send(ctx) addedtime = 0 if gwtime[0] == "seconds": addedtime = gwtime[1] elif gwtime[0] == "minutes": addedtime = 60 * gwtime[1] elif gwtime[0] == "hours": addedtime = 60 * 60 * gwtime[1] elif gwtime[0] == "days": addedtime = 24 * 60 * 60 * gwtime[1] if requirements == {}: reqs = 'none' else: reqs = ''.join(list(str(requirements))[1:-1]) try: 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) embed = Embed( ':tada: Giveaway :tada:', f'\n\n**Entry:** React with {random_lacan}!\n\n**Prize:** {prize}\n\n**Winners:** {winners}\n\n**Hosted by:** {ctx.author.mention}', timestamp=(datetime.fromtimestamp( int( int(datetime.timestamp(datetime.now())) + addedtime))), color=0x00FF00) '''embed.field('Prize', gwcontent) embed.field('Winners', winners) embed.field('To Enter', f'React With {random_lacan} !')''' embed.field('Requirements', reqs) embed.footer('Ends at') c = discord.utils.get(ctx.guild.channels, id=int(channel)) '''message = await c.send(content=":partying_face:", embed=embed.default_embed())''' message = await c.send(embed=embed.default_embed()) await message.add_reaction(random_lacan) except: embed = Embed( ':tada: Giveaway :tada:', f'\n\n**Entry:** React with :moneybag:!\n\n**Prize:** {prize}\n\n**Winners:** {winners}\n\n**Hosted by:** {ctx.author.mention}', timestamp=(datetime.fromtimestamp( int( int(datetime.timestamp(datetime.now())) + addedtime))), color=0x00FF00) '''embed.field('Prize', prize) embed.field('Winners', winners) embed.field('To Enter', 'React With :moneybag: !')''' embed.field('Requirements', reqs) embed.footer('Ends at') c = discord.utils.get(ctx.guild.channels, id=int(channel)) message = await c.send( content= "I am missing `Use external emoji` permissions. Make sure to give me those in order to enjoy giveaways even more!", embed=embed.default_embed()) #message = await c.send(embed=embed.default_embed()) await message.add_reaction('💰') dbclient = DBClient() collection = dbclient.db.giveaways await dbclient.create_doc( collection, { "endtime": int(int(datetime.timestamp(datetime.now())) + addedtime), "messageID": message.id, "channelID": message.channel.id, "ended": False, "requirements": requirements, "gwcontent": prize, "winners": winners }) print('gw in db') else: embed = Embed( 'Error!' 'You gave an invalid response! Your giveaway has been canceled.' ) return await embed.send(ctx)