· 5 years ago · Sep 09, 2020, 04:20 PM
1# obtain proper libraries for hypixel stats and discord.py
2import discord
3from discord.ext import commands
4import aiohttp
5import asyncpraw
6import random
7
8#initialize discord.py and hypixel api
9client = commands.Bot(command_prefix = ".")
10
11reddit = asyncpraw.Reddit(client_id="no",
12 client_secret="no",
13 user_agent="script: Python (by /u/no)")
14
15
16@client.command()
17async def hystats(ctx,mcuser):
18 async with aiohttp.ClientSession() as cs:
19 async with cs.get(f'https://api.slothpixel.me/api/players/{mcuser}') as r:
20 res = await r.json() # returns dict
21 await ctx.send(res['total_coins'])
22
23
24
25#sends a message to the console when the bot is connected
26@client.event
27async def on_ready():
28 print(f"{client.user} is ready!")
29
30
31#basic ping command
32@client.command(brief = "Tells you the ping in ms", description = "Tells you the time to connect from idiot.exes pc to the discord server (in ms)")
33async def ping(ctx):
34 await ctx.send(f"pong! {round(client.latency * 1000, 4)} ms")
35
36
37#funny meme command
38@client.command(brief = "haha brrr go brrrr", description = "brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr")
39async def brr(ctx):
40 await ctx.send("https://i.clouds.tf/hys8/7nvo.png")
41
42
43
44
45
46#links the skyleamoe page for a given user
47@client.command()
48async def sbprof(ctx,mcname):
49 await ctx.send(f"https://sky.lea.moe/stats/{mcname}")
50
51@client.command()
52async def meme(ctx):
53 memesubs = ["memes","dankmemes"]
54 subreddit = await reddit.subreddit(random.choice(memesubs))
55 submission = await subreddit.random()
56 await ctx.send(submission.url)
57
58
59
60
61
62
63
64#uses my api key to run the code and start sending it over to discord
65client.run("no")
66