async def blacklist(self, ctx, user: discord.Member):
     if not self.owner_check(ctx.author.id):
         await ctx.send(
             "DON'T BE SHADY... :eyes:\nThis command is owner only. :x:")
     else:
         ezjson.dump("data/blacklist.json", ctx.author.id, True)
         await ctx.send(
             "Success. :white_check_mark: The user is now put on the blacklist. :smiling_imp: "
         )
Beispiel #2
0
 async def crsave(self, ctx, crtag=None):
     """Saves your CR tag to your account. Usage: *crsave [player tag]"""
     if crtag is None:
         return await ctx.send(
             "Please enter a tag to save. Usage: *crsave [tag]")
     if not self.check_tag(crtag):
         return await ctx.send(
             "That must be an invalid tag. Please use a valid tag. :x:")
     ezjson.dump("data/crtags.json", ctx.author.id, crtag)
     await ctx.send(
         "Success. :white_check_mark: Your tag is now saved to your account."
     )
Beispiel #3
0
 async def prefix(self, ctx, prefix=None):
     em = discord.Embed(color=discord.Color(value=0x00ff00),
                        title="Bot Prefix")
     if prefix is None:
         em.description = f"The bot's prefix for server **{ctx.guild.name}** is set to `{ctx.prefix}`."
         return await ctx.send(embed=em)
     if prefix.lower() == 'clear':
         ezjson.dump("data/prefix.json", ctx.guild.id, "*")
         em.description = f"The bot's prefix is now set to the default: `*`."
         return await ctx.send(embed=em)
     else:
         ezjson.dump("data/prefix.json", ctx.guild.id, prefix)
         em.description = f"The bot's prefix for this server is set to: `{prefix}`."
         return await ctx.send(embed=em)
Beispiel #4
0
 async def dailycredit(self, ctx):
     '''Collect your daily bananas!'''
     num = random.randint(100, 200)
     f = open("data/economy.json").read()
     x = json.loads(f)
     try:
         x[str(ctx.guild.id)][str(ctx.author.id)]
     except KeyError:
         return await ctx.send("Oof. You don't have an account yet! Time to create one with `*openaccount`.")
     lol = {
         str(ctx.author.id): int(x[str(ctx.guild.id)][str(ctx.author.id)]) + num
     }
     ezjson.dump("data/economy.json", ctx.guild.id, lol)
     return await ctx.send(f"Hooray! Successfully added **{num}** :banana: into your account.")
Beispiel #5
0
 async def cocsave(self, ctx, coctag=None):
     '''Saves a Clash of Clans tag to your Discord account.'''
     if coctag is None:
         return await ctx.send(
             'Oops! Enter a tag to save! Usage: *cocsave [tag]')
     coctag = coctag.strip('#')
     for char in coctag:
         if char.upper() not in '0289PYLQGRJCUV':
             return await ctx.send(
                 f'Oops again! Looks like your tag `#{coctag}` is not a valid tag!'
             )
     ezjson.dump("data/coctags.json", ctx.author.id, coctag)
     await ctx.send(
         "Success. :white_check_mark: Your tag is now saved to your account."
     )
Beispiel #6
0
 async def modlog(self, ctx, action=None):
     if action is None:
         x = await self.bot.db.modlog.find_one({"id": str(ctx.guild.id)})
         em = discord.Embed(color=discord.Color(value=0x00ff00),
                            title="Mod Log Status")
         em.description = f"Mod logs are enabled in this server, in <#{x['channel']}>."
         if x is None:
             em.description = 'Mod logs are turned off for this server.'
         return await ctx.send(embed=em)
     if action.lower() == 'on':
         await ctx.send(
             "Please mention the channel for mod logs to be sent in.")
         try:
             x = await self.bot.wait_for("message",
                                         check=lambda x: x.channel == ctx.
                                         channel and x.author == ctx.author,
                                         timeout=60.0)
         except asyncio.TimeoutError:
             return await ctx.send("Request timed out. Please try again.")
         if not x.content.startswith("<#") and not x.content.endswith(">"):
             return await ctx.send("Please properly mention the channel.")
         channel = x.content.strip("<#").strip(">")
         try:
             channel = int(channel)
         except ValueError:
             return await ctx.send(
                 "Did you properly mention a channel? Probably not.")
         await self.bot.db.modlog.update_one({"id": str(ctx.guild.id)},
                                             {"$set": {
                                                 "channel": channel
                                             }},
                                             upsert=True)
         ezjson.dump("data/modlog.json", ctx.guild.id, channel)
         return await ctx.send(
             f"Successfully turned on Mod Logs in <#{channel}>. Enjoy! :white_check_mark:"
         )
     if action.lower() == 'off':
         await self.bot.db.modlog.update_one({"id": str(ctx.guild.id)},
                                             {"$set": {
                                                 "channel": False
                                             }},
                                             upsert=True)
         return await ctx.send("Turned off Mod Logs. Whew...")
     else:
         return await ctx.send(
             "That ain't an action. Please enter either `on` or `off`.")
Beispiel #7
0
 async def welcomemsg(self, ctx, action=None):
     if action is None:
         em = discord.Embed(color=discord.Color(value=0x00ff00),
                            title='Welcome Messages')
         try:
             f = open("data/welcomemsg.json").read()
             x = json.loads(f)
             if x[str(ctx.guild.id)] is False:
                 em.description = 'Welcome messages are disabled for this server.'
             else:
                 em.description = f'Welcome messages are turned on for this server, set in <#{x[str(ctx.guild.id)]}>.'
         except KeyError:
             em.description = 'Welcome messages are disabled for this server.'
         await ctx.send(embed=em)
     else:
         if action.lower() == 'on':
             await ctx.send(
                 "Please mention the channel to set welcome messages in.")
             try:
                 x = await self.bot.wait_for(
                     "message",
                     check=lambda x: x.channel == ctx.channel and x.author
                     == ctx.author,
                     timeout=60.0)
             except asyncio.TimeoutError:
                 return await ctx.send(
                     "Request timed out. Please try again.")
             if not x.content.startswith("<#") and not x.content.endswith(
                     ">"):
                 return await ctx.send(
                     "Please properly mention the channel.")
             channel = x.content.strip("<#").strip(">")
             try:
                 channel = int(channel)
             except ValueError:
                 return await ctx.send(
                     "Did you properly mention a channel? Probably not.")
             ezjson.dump("data/welcomemsg.json", ctx.guild.id, channel)
             await ctx.send(
                 "Successfully turned on welcome messages for this guild.")
         elif action.lower() == 'off':
             ezjson.dump("data/welcomemsg.json", ctx.guild.id, False)
             await ctx.send(
                 "Successfully turned off welcome messages for this guild.")
Beispiel #8
0
 async def lottery(self, ctx, numbers: str = None):
     '''Enter the lottery to win/lose! 3 numbers, seperate with commas. Entry is $50, winner gets $10 million!'''
     f = open("data/economy.json").read()
     x = json.loads(f)
     try:
         x[str(ctx.guild.id)][str(ctx.author.id)]
     except KeyError:
         return await ctx.send("Oof. You don't have an account yet! Time to create one with `*openaccount`.")
     if int(x[str(ctx.guild.id)][str(ctx.author.id)]) < 100:
         return await ctx.send("Entering the lottery requires 100 :banana:. You don't have enough! Keep on earning 'em")
     if numbers is None:
         return await ctx.send("Please enter 3 numbers seperated by commas to guess the lottery! \nExample: *lottery 1,2,3")
     numbers = numbers.replace(' ', '')
     numbers = numbers.split(',')
     lucky = [str(random.randint(0, 9)), str(random.randint(0, 9)), str(random.randint(0, 9))]
     for i in numbers:
         try:
             int(i)
         except ValueError:
             return await ctx.send("Please enter only numbers for the lottery!")
     lol = ""
     for x in lucky:
         lol += f"`{x}` "
     if numbers == lucky:
         lol = {
             str(ctx.author.id): x[str(ctx.guild.id)][str(ctx.author.id)] + 10000000
         }
         ezjson.dump("data/economy.json", ctx.guild.id, lol)
         em = discord.Embed(color=discord.Color(value=0x00ff00), title='You are the lucky winner!')
         em.description = 'Awesome job! You are part of the 0.8% population that won the lottery! :tada:\n\nYou won 10,000,000 :banana:!'
         return await ctx.send(embed=em)
     else:
         lol = {
             str(ctx.author.id): x[str(ctx.guild.id)][str(ctx.author.id)] - 100
         }
         ezjson.dump("data/economy.json", ctx.guild.id, lol)
         em = discord.Embed(color=discord.Color(value=0xf44e42))
         em.description = f"Ouch. You are part of the 99.2% population that didn't cut it! ¯\_(ツ)_/¯\n\nThe winning numbers were: \n{lol}\n\nYou lost: 100 :banana:"
         return await ctx.send(embed=em)
Beispiel #9
0
	relpage1 = Page('Some page')
	relpage2 = Page('Another some page')

	page = Page(
		'Master page',
		'''Phasellus nascetur urna rhoncus nisi et. Dignissim "turpis" tempor et, in, vel mattis. Eros urna lectus, 'magna' cum! Turpis risus "turient" nunc. Tristique dis? In a facilisis''',
		['#tag1', '#tag2', '#tag3', '#tag4', '#tag5']
	)

	print
	print('################### ezjson test ###################')
	print
	print('         ######## JSON Encoding ########           ')
	print
	print(json.dump(page, max_depth=3))
	print
	page.related_pages = (relpage1, relpage2)
	page.published = True
	page.date_published = datetime.datetime.now()
	print(json.dump(page, max_depth=3))
	print
	print
	print('         ######## JSON Decoding ########           ')
	print
	_json = json.dump(page, max_depth=3)
	print('             ####### as dict #######               ')
	print
	print( json.load(_json) )
	print
	print('            ####### as object #######              ')