Пример #1
0
	async def reginald_request_data(self,ctx:SlashContext):
		userdata = save.read(['users',str(ctx.author.id)])
		response = []
		response.append(f'known guilds: {userdata["guilds"]}')
		response.append(f'birthday: {userdata["birthday"]}')
		await ctx.send(embed=discord.Embed(title=f'{ctx.author.name}\'s data',description='\n\n'.join(response),color=0x69ff69),hidden=True)
		logOutput(f'data requested',ctx)
Пример #2
0
	async def ricepurity_test(self,ctx:SlashContext):
		await ctx.send('starting rice purity test...')
		channel = await client.fetch_channel(ctx.channel_id)
		message = await channel.send(f'{ctx.author.name}\nDo you want to take the rice purity test?',buttons=ynButtons)
		try: answer = await ddb.wait_for_button_click(message,None,60)
		except: await channel.send('test timed out'); return
		if answer.button.label == 'No': await message.edit('THEN WHY\'D YOU RUN THE COMMAND?'); await answer.respond(); return
		index = 1
		score = 100
		answers = []
		for question in rice.read(['test']):
			await message.edit(f'{ctx.author.name}\n{index}. {question}')
			await answer.respond()
			try: answer = await ddb.wait_for_button_click(message,None,60)
			except: await channel.send('test timed out'); return
			if index == 101 and answer.button.label == 'Yes': score = f'h{score}'; continue
			match answer.button.label:
				case 'Yes': answers.append(1); score -= 1
				case 'No': answers.append(0)
			index += 1
		await answer.respond()
		save.write(str(score),['users',str(ctx.author.id),'ricePurityScore'])
		rice.write(answers,['results',str(ctx.author.id)])
		rice.save()
		await ctx.author.send(f'Thank you for taking the rice purity test. Your score is {score}')
		logOutput('rice purity test taken',ctx)
Пример #3
0
	async def reginald_info(self,ctx:SlashContext):
		embed = discord.Embed(title='Reginald Info:',description="""a mash up of the server mcstarter, the discipline sticc, and the mcfuck.\n
		please submit any issues using /reginald issue\n
		and if you have any suggestions, you can use /reginald suggest\n
		you can follow development here: https://discord.gg/4mteVXBDW7\n
		thank you, all hail reginald.""",color=0x69ff69)
		await ctx.send(embed=embed)
		logOutput(f'reginald info requested',ctx)
Пример #4
0
	async def reginald_poll(self,ctx:SlashContext,title:str,description:str,optiona:str,optionb:str,optionc=None,optiond=None,other:discord.TextChannel=None):
		options = ['🇦','🇧']
		description = f'{description}\n\n🇦: {optiona}\n🇧: {optionb}'
		if optionc != None: description = f'{description}\n🇨: {optionc}'; options.append('🇨')
		if optiond != None: description = f'{description}\n🇩: {optiond}'; options.append('🇩')
		if other != None: description = f'{description}\nOther: please specify in {other}'; options.append('🇴')
		message = await ctx.send(embed=discord.Embed(title=title,description=description))
		for i in options: await message.add_reaction(i)
		logOutput('poll created',ctx)
Пример #5
0
 async def crypto_calculate_zano(self, ctx: SlashContext, hashrate: float,
                                 holdings: float):
     await ctx.defer()
     try:
         exchRate = float(
             json.loads(
                 requests.get('https://api.coingecko.com/api/v3/coins/zano')
                 .text)['market_data']['current_price']['usd'])
     except:
         await ctx.send('failed to fetch exchange rate', hidden=True)
         return
     try:
         zanoExplorer = json.loads(
             requests.get(
                 'https://explorer.zano.org/api/get_info/4294967295').text
         )['result']
     except:
         await ctx.send('failed to fetch network hashrate', hidden=True)
         return
     hashrate = float(hashrate)
     holdings = float(holdings)
     response = []
     response.append(f'Your hashrate: {hashrate} MH/s')
     response.append(f'Your holdings: {holdings} Zano')
     response.append(f'Your USD: ${round(holdings*exchRate,3)}')
     hashrate = hashrate * 1000000
     posDiff = int(zanoExplorer['pos_difficulty'])
     networkHash = int(zanoExplorer['current_network_hashrate_350'])
     timeToBlock = round(100 / (hashrate / networkHash * 100 / 2), 2)
     zanoDay = round(1440 / (100 / (hashrate / networkHash * 100)), 3) / 2
     usdDay = round(
         1440 / (100 / (hashrate / networkHash * 100)) * exchRate, 3) / 2
     posEarnings = holdings * 720 / (posDiff / 1000000000000 / 100)
     response.append(
         f'Network hashrate: {round(networkHash/1000000000,3)} GH/s')
     response.append(f'Zano price: ${format(exchRate,".3f")}')
     response.append(
         f'Chance of mining next block: {format(round(hashrate/networkHash*100/2,3),".3f")}%'
     )
     response.append(
         f'Est. time to PoW mine block: {timeToBlock} minutes | {round(timeToBlock/60,2)} hours'
     )
     response.append(
         f'Est. time to PoS mine block: {round(100/posEarnings,2)} minutes | {round(100/posEarnings/60,2)} hours'
     )
     response.append(f'Est. PoS Earnings: {round(posEarnings,5)} Zano')
     response.append(f'Zano/day: {zanoDay}')
     response.append(f'Zano/month: {round(zanoDay*30,3)}')
     response.append(f'Zano/year: {round(zanoDay*365,3)}')
     response.append(f'USD/day: ${usdDay}')
     response.append(f'USD/month: ${round(usdDay*30,3)}')
     response.append(f'USD/year: ${round(usdDay*365,3)}')
     await ctx.send(embed=discord.Embed(title='Your Zano Stats:',
                                        description='\n'.join(response),
                                        color=0x69ff69))
     logOutput(f'zano stats requested', ctx)
Пример #6
0
	async def minecraft_info(self,ctx:SlashContext,server:str):
		info = []
		try:
			for i in servers.read([server]):
				if i=='directory' or i=='isModded' or i=='mods': continue
				info.append(f'{i}: {servers.read([server,i])}')
		except: await ctx.send('server name error')
		info.append('modpack: vanilla') if not servers.read([server,'isModded']) else info.append(f'modpack: https://mods.nutt.dev/{server}')
		info.append(f'size: {serverMcstarter.getServerSize(server)}')
		await ctx.send(embed=discord.Embed(title=f'{server} info:',description='\n'.join(info),color=0x69ff69))
		logOutput(f'info about server {server} requested',ctx)
Пример #7
0
	async def roll(self,ctx:SlashContext,dice:int,sides:int,modifiers:int=0):
		try: maxRoll = save.read(['servers',str(ctx.guild.id),'config','maxRoll'])
		except: maxRoll = 16384
		await ctx.defer()
		if dice > maxRoll or sides > maxRoll or dice < 0 or sides < 0: await ctx.send(f'rolls must be between 0 and {maxRoll}!'); return
		result = modifiers
		rolls = []
		for i in range(dice): roll = randint(1,sides); rolls.append(str(roll)); result+=roll
		try: await ctx.send(embed=discord.Embed(title=f'roll: {dice}d{sides}+{modifiers}' if modifiers>0 else f'roll: {dice}d{sides}',color=0x69ff69).add_field(name='rolls:',value=f'[{",".join(rolls)}]',inline=False).add_field(name='Result:',value=result,inline=False))
		except: await ctx.send(embed=discord.Embed(title=f'roll: {dice}d{sides}+{modifiers}' if modifiers>0 else f'roll: {dice}d{sides}',color=0x69ff69).add_field(name='rolls:',value='total rolls above character limit.',inline=False).add_field(name='Result:',value=result,inline=False))
		logOutput(f'roll {dice}d{sides}+{modifiers} requested',ctx)
Пример #8
0
 async def birthday_set(self, ctx: SlashContext, month: int, day: int):
     if int(month) > 12 or int(day) > 31:
         await ctx.send('invalid date.')
         return
     save.write(f'{month.zfill(2)}/{day.zfill(2)}',
                ['users', str(ctx.author.id), 'birthday'])
     await ctx.send(
         f"birthday successfully set to {save.read(['users',str(ctx.author.id),'birthday'])}"
     )
     logOutput(
         f"birthday set to {save.read(['users',str(ctx.author.id),'birthday'])}",
         ctx)
Пример #9
0
	async def start(self,ctx:SlashContext,server:str):
		if serverStarted: return
		try: os.chdir(servers([server,'directory']))
		except: await ctx.send('server name error')
		os.startfile('botStart.bat')
		os.chdir(mainDirectory)
		await ctx.send('okay, it\'s starting.')
		for i in range(save.read(['servers',str(ctx.guild.id),'config','maxServerStartTime'])):
			try: MinecraftServer.lookup(serverQuery).query().players.online; break
			except: asyncio.sleep(1)
		else: await ctx.send('error starting server.'); return
		await ctx.send('it should be up.')
		logOutput(f'starting server {server}',ctx)
Пример #10
0
	async def reginald_ignore(self,ctx:SlashContext,mode:str,user:discord.User):
		ignoreList = save.read(['servers',str(ctx.guild.id),'ignore'])
		match mode:
			case 'add':
				if user.id in ignoreList: await ctx.send('this user is already on the ignore list!'); return
				ignoreList.append(user.id)
				await ctx.send(f"successfully added {user.name} to ignore list.")
			case 'remove':
				if user.id not in ignoreList: await ctx.send('this user is not on the ignore list!'); return
				ignoreList.remove(user.id)
				await ctx.send(f"successfully removed {user.name} from ignore list.")
		save.write(ignoreList,['servers',str(ctx.guild.id),'ignore'])
		logOutput(f'{user.name} added to ignore list',ctx)
Пример #11
0
	async def leaderboard_messages(self,ctx:SlashContext):
		save.write({key:value for key,value in sorted(save.read(['variables','messages']).items(),key=lambda item: item[1],reverse=True)},['variables','messages'])
		names = []
		index = 1
		await ctx.defer()
		for member in save.read(['variables','messages']):
			if index > 50: break
			if member not in save.read(['variables','idNameCache']):
				try: save.write((await client.fetch_user(member)).name,['variables','idNameCache',member])
				except: continue
			rank = str(index)+("th" if 4<=index%100<=20 else {1:"st",2:"nd",3:"rd"}.get(index%10, "th")); index += 1
			names.append(f"{rank} - {save.read(['variables','idNameCache',member])}: {save.read(['variables','messages',member])}")
		await ctx.send(embed=discord.Embed(title='Messages:',description='\n'.join(names),color=0x69ff69))
		logOutput(f'message leaderboard requested',ctx)
Пример #12
0
	async def get_profile(self,ctx:SlashContext,user:discord.User):
		description = []
		description.append(f'creation date: {user.created_at.strftime("%m/%d/%Y %H:%M:%S")}')
		description.append(f'display name: {user.display_name}')
		guilds = ",\n- ".join([i.name for i in user.mutual_guilds])
		description.append(f'mutual guilds:\n  - {guilds}')
		description.append(f"birthday: {save.read(['users',str(user.id),'birthday'])}")
		description.append(f"rice purity score: hidden" if save.read(['users',str(user.id),'ricePurityScore']).startswith('h') else f"rice purity score: {save.read(['users',str(user.id),'ricePurityScore'])}")
		embed = discord.Embed(title=f'{user.name}\'s profile',description=f'id: {user.id}\nname: {user.name}\ndiscriminator: {user.discriminator}',color=0x69ff69)
		embed.set_thumbnail(url=user.avatar.with_format('png').with_size(512).url)
		embed.add_field(name='information:',value='\n'.join(description))
		user.avatar.with_format('png')
		await ctx.send(embed=embed)
		logOutput(f'profile of {user.name} requested',ctx)
Пример #13
0
 async def birthday_setup(self, ctx: SlashContext, role: discord.Role,
                          channel: discord.TextChannel):
     if not save.read(
         ['servers',
          str(ctx.guild.id), 'config', 'enableBirthdays']):
         await ctx.send(embed=discord.Embed(
             title='Birthdays is not enabled on this server.',
             color=0x69ff69))
         return
     save.write(role.id, ['servers', str(ctx.guild.id), 'birthdayRole'])
     save.write(channel.id,
                ['servers', str(ctx.guild.id), 'birthdayChannel'])
     await ctx.send(
         f'successfully set birthday role to {role.mention} and birthday channel to {channel.mention}'
     )
     logOutput(
         f'birthday role set to {role.name} and birthday channel set to {channel.name}',
         ctx)
Пример #14
0
 async def reginald_issue(self, ctx: SlashContext, issue: str,
                          details: str):
     await ctx.defer()
     issueCount = save.read(['information', 'issueCount'])
     issueCount += 1
     channel = await client.fetch_channel(
         save.read(['information', 'issues-channel']))
     message = await channel.send(embed=discord.Embed(
         title=f"{issue} | #{issueCount}",
         description=
         f'suggested by: {ctx.author.mention}\n\ninformation:\n{details}',
         color=0x69ff69))
     for i in ['<:open:847372839732379688>', '👍', '👎']:
         await message.add_reaction(i)
     save.action('append', int(message.jump_url.split('/')[-1]),
                 ['variables', 'issues'])
     save.write(issueCount, ['information', 'issueCount'])
     await ctx.send('thank you for reporting this issue!')
     logOutput(f'new issue {issue}', ctx)
Пример #15
0
 async def crypto_exchange(self, ctx: SlashContext, coin: str, amount: int):
     if '..' in coin:
         await ctx.send('invalid coin name.')
         return
     try:
         exchRate = float(
             json.loads(
                 requests.get(
                     f'https://api.coingecko.com/api/v3/coins/{coin.lower()}'
                 ).text)['market_data']['current_price']['usd'])
     except:
         await ctx.send(
             'failed to fetch exchange rate. is the coin name correct?',
             hidden=True)
         return
     await ctx.send(
         f'{format(float(amount),",.3f")} {coin} = ${format(exchRate*int(amount),",.3f")} USD'
     )
     logOutput(f'exchange rate for {amount} {coin}', ctx)
Пример #16
0
 async def reginald_suggest(self, ctx: SlashContext, suggestion: str,
                            details: str):
     await ctx.defer()
     suggestCount = save.read(['information', 'suggestCount'])
     suggestCount += 1
     if r'\n' in details: details = '- ' + '\n- '.join(details.split(r'\n'))
     channel = await client.fetch_channel(
         save.read(['information', 'suggestions-channel']))
     message = await channel.send(embed=discord.Embed(
         title=f"{suggestion} | #{suggestCount}",
         description=
         f'suggested by: {ctx.author.mention}\n\ndetails:\n{details}',
         color=0x69ff69))
     for i in ['👍', '👎']:
         await message.add_reaction(i)
     await ctx.send('thank you for your suggestion!')
     save.action('append', int(message.jump_url.split('/')[-1]),
                 ['variables', 'suggestions'])
     save.write(suggestCount, ['information', 'suggestCount'])
     logOutput(f'new suggestion "{suggestion}"', ctx)
Пример #17
0
 async def reginald_dev_commit(self,
                               ctx: SlashContext,
                               title: str,
                               features: str = None,
                               fixes: str = None,
                               notes: str = None,
                               newversion: bool = True,
                               test: bool = False):
     await ctx.defer()
     if newversion: save.math('+', 0.01, ['information', 'version'])
     version = round(save.read(['information', 'version']), 2)
     channel = await client.fetch_channel(
         844133317041061899) if test else await client.fetch_channel(
             save.read(['information', 'change-log-channel']))
     response = f'version: {format(version,".2f")}\n\n'
     if features != None:
         features = '- ' + '\n- '.join(features.split(r'\n'))
         response += f'features:\n{features}\n\n'
     if fixes != None:
         fixes = '- ' + '\n- '.join(fixes.split(r'\n'))
         response += f'fixes / changes:\n{fixes}\n\n'
     if notes != None:
         notes = '- ' + '\n- '.join(notes.split(r'\n'))
         response += f'notes:\n{notes}\n\n'
     response += f'these features are new, remember to report bugs with /reginald issue\ncommands may take up to an hour to update globally.\n[development server](<https://discord.gg/4mteVXBDW7>)'
     for i in re.findall(r'issue\d+', response):
         response = re.sub(
             r'issue\d+',
             f"([issue#{i.split('issue')[1]}](<https://discord.com/channels/844127424526680084/844131633787699241/{save.read(['variables','issues',int(i.split('issue')[1])-1])}>))",
             response, 1)
     for i in re.findall(r'suggestion\d+', response):
         response = re.sub(
             r'suggestion\d+',
             f"([suggestion#{i.split('suggestion')[1]}](<https://discord.com/channels/844127424526680084/844130469197250560/{save.read(['variables','suggestions',int(i.split('suggestion')[1])-1])}>))",
             response, 1)
     message = await channel.send(embed=discord.Embed(
         title=title, description=response, color=0x69ff69))
     if not test: await message.publish()
     await ctx.send('successfully pushed change.')
     logOutput(f'new commit pushed', ctx)
Пример #18
0
	async def reginald_8ball(self,ctx:SlashContext,question:str):
		await ctx.send(eightBallResponses[randint(0,len(eightBallResponses)-1)])
		logOutput('8ball rolled',ctx)
Пример #19
0
	async def get_guild(self,ctx:SlashContext,guild:int):
		await ctx.send((await client.fetch_guild(int(guild))).name)
		logOutput(f'guild {guild} requested',ctx)
Пример #20
0
	async def reginald_time(self,ctx:SlashContext):
		await ctx.send(datetime.now().strftime("%H:%M:%S"))
		logOutput(f'time requested',ctx)
Пример #21
0
 async def clearIDcache(self, ctx: SlashContext):
     save.write({}, ['variables', 'idNameCache'])
     await ctx.send('successfully cleared ID cache')
     logOutput(f'idNameCache cleared', ctx)
Пример #22
0
	async def hello_reginald(self,ctx:SlashContext):
		await ctx.send(file=discord.File('reginald.png'))
		logOutput(f'said hi to reginald',ctx)
Пример #23
0
	async def qotd_setup(self,ctx:SlashContext,channel:discord.TextChannel):
		if not save.read(['servers',str(ctx.guild.id),'config','enableQOTD']): await ctx.send(embed=discord.Embed(title='The QOTD is not enabled on this server.',color=0x69ff69)); return
		save.write(channel.id,['servers',str(ctx.guild.id),'qotdChannel'])
		await ctx.send(embed=discord.Embed(title='Setup Complete.',description=f'channel: <#{channel.id}>',color=0x69ff69))
		logOutput(f'qotd setup',ctx)
Пример #24
0
	async def quotes_setup(self,ctx:SlashContext,channel:discord.TextChannel):
		await ctx.send('quotes are temporarily disabled until I actually have some.'); return
		if not save.read(['servers',str(ctx.guild.id),'config','enableQuotes']): await ctx.send(embed=discord.Embed(title='Quotes are not enabled on this server.',color=0x69ff69)); return
		save.write(channel.id,['servers',str(ctx.guild.id),'quoteChannel'])
		await ctx.send(embed=discord.Embed(title='Setup Complete.',description=f'channel: <#{channel.id}>',color=0x69ff69))
		logOutput(f'quotes setup',ctx)
Пример #25
0
 async def birthday_remove(self, ctx: SlashContext):
     save.write(None, ['users', str(ctx.author.id), 'birthday'])
     await ctx.send(f'birthday successfully reset')
     logOutput(f'birthday reset', ctx)
Пример #26
0
	async def stop(self,ctx:SlashContext,args:str=None):
		if MinecraftServer.lookup(serverQuery).query().players.online > 0:
			if not (args == '-f' and adminOrOwner()): await ctx.send('no, f**k you, there are people online.'); return
		try: mc.connect(); mc.command('stop'); mc.disconnect(); serverStarted = False; await ctx.send('stopping server.')
		except: await ctx.send('failed to shutdown server.'); return
		logOutput(f'stopping server',ctx)
Пример #27
0
 async def reginald_dev_asyncExecute(self, ctx: SlashContext,
                                     function: str):
     await ctx.send(str(await eval(function)), hidden=True)
     logOutput(f'{function} executed', ctx)
Пример #28
0
	async def get_name(self,ctx:SlashContext,user:int):
		await ctx.send((await client.fetch_user(int(user))).name)
		logOutput(f'name of {user} requested',ctx)
Пример #29
0
	async def online(self,ctx:SlashContext):
		try: players = MinecraftServer.lookup(serverQuery).query().players.names
		except: await ctx.send('cannot connect to server. is it online?'); return
		if players == []: await ctx.send('no one is online.'); return
		await ctx.send(embed=discord.Embed(title='Players Online:',description='\n'.join(players),color=0x69ff69))
		logOutput(f'online players requested',ctx)
Пример #30
0
	async def cmd(self,ctx:SlashContext,command:str):
		try: mc.connect(); response = mc.command(command); mc.disconnect()
		except: await ctx.send('failed to send command'); return
		try: await ctx.send(re.sub('§.','',response))
		except: pass
		logOutput(f'command {command} run',ctx)