Skip to content

Commit b1ab1d4

Browse files
authored
V.0.0.1.6 Release
V.0.0.1.6 Release
2 parents e56b0a5 + 93fd8d0 commit b1ab1d4

File tree

8 files changed

+50
-28
lines changed

8 files changed

+50
-28
lines changed

Teapot.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@
4848
print("An error occurred while fetching the latest Teapot.py version. [503 Service Unavailable]\n")
4949
else:
5050
print("An unknown error has occurred when fetching the latest Teapot.py version\n")
51-
print("Error Code:" + str(req.status_code))
51+
print("HTML Error Code:" + str(req.status_code))
5252

5353
load_dotenv(join(dirname(__file__), '.env'))
5454

5555
if os.getenv('CONFIG_VERSION') != teapot.config_version():
5656
if os.path.isfile('.env'):
57-
print("Missing environment variables. Please backup and delete .env, then run Teapot.py again.")
57+
print("Missing environment variables. Please backup and delete .env, then run Teapot.py again.")
5858
quit(2)
59-
print("Unable to find required environment variables. Running setup.py...")
60-
teapot.setup.__init__()
59+
print("Unable to find required environment variables. Running setup.py...") # if .env not found
60+
teapot.setup.__init__() # run setup.py
6161

6262
print("Initializing bot...")
63-
if teapot.config.storage_type() == "mysql":
63+
if teapot.config.storage_type() == "mysql": # if .env use mysql, create the table if table not exists
6464
time_start = time.perf_counter()
6565
database = teapot.managers.database.__init__()
6666
db = teapot.managers.database.db(database)
@@ -101,17 +101,18 @@ async def on_ready():
101101
for guild in bot.guilds:
102102
teapot.managers.database.create_guild_table(guild)
103103
elif teapot.config.storage_type() == "sqlite":
104-
print("[!] SQLite storage has not been implemented yet. MySQL database is recommended")
104+
print("[!] Warning: SQLite storage has not been implemented yet. MySQL database is recommended") # WIP
105105
print(f"Registered commands and events in {round(time.perf_counter() - time_start, 2)}s")
106-
await bot.change_presence(status=discord.Status.online, activity=discord.Game(teapot.config.bot_status()))
106+
await bot.change_presence(status=discord.Status.online, activity=discord.Game(teapot.config.bot_status())) # Update Bot status
107107

108108

109109

110110
try:
111111
discord_time_start = time.perf_counter()
112112
bot.run(teapot.config.bot_token())
113113
except Exception as e:
114-
print(f"[/!\\] Failed to connect to DiscordAPI. Please check your bot token!\n{e}")
114+
print(f"[/!\\] Error: Failed to connect to DiscordAPI. Please check your bot token!\n{e}")
115115
if teapot.config.storage_type() == "mysql":
116116
db.execute("INSERT INTO `bot_logs`(timestamp, type, class, message) VALUES(%s, %s, %s, %s)",
117117
(teapot.time(), "ERROR", __name__, e))
118+
exit(9)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ beautifulsoup4==4.8.2
55
bs4==0.0.1
66
certifi==2019.11.28
77
chardet==3.0.4
8-
discord.py==1.3.0
8+
discord.py==1.3.3
99
idna==2.8
1010
lavalink==3.1.1
1111
multidict==4.7.4

teapot/cogs/cat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,30 @@ async def cat(self, ctx):
2121
""" Get a cat image """
2222
req = requests.get('https://api.thecatapi.com/v1/images/search')
2323
if req.status_code != 200:
24+
await ctx.message.add_reaction(emoji='❌')
25+
await ctx.send("API error, could not get a meow")
2426
print("Could not get a meow")
2527
catlink = json.loads(req.text)[0]
2628
rngcat = catlink["url"]
2729
em = dmbd.newembed()
2830
em.set_image(url=rngcat)
2931
await ctx.send(embed=em)
32+
await ctx.message.add_reaction(emoji='✅')
3033

3134
@commands.command(pass_context=True, aliases=['woof'])
3235
async def dog(self, ctx):
3336
""" Get a dog image """
3437
req = requests.get('http://random.dog/')
3538
if req.status_code != 200:
39+
await ctx.message.add_reaction(emoji='❌')
40+
await ctx.send("API error, could not get a woof")
3641
print("Could not get a woof")
3742
doglink = BeautifulSoup(req.text, 'html.parser')
3843
rngdog = 'http://random.dog/' + doglink.img['src']
3944
em = dmbd.newembed()
4045
em.set_image(url=rngdog)
4146
await ctx.send(embed=em)
47+
await ctx.message.add_reaction(emoji='✅')
4248

4349

4450
def setup(bot):

teapot/cogs/cmds.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def help(ctx, *cog):
7272
def info(bot):
7373
@bot.command(aliases=['about'])
7474
async def info(ctx):
75-
embed = discord.Embed(title="Developers: ColaIan, RedTea", description="Multi-purpose Discord Bot",
75+
embed = discord.Embed(title="Developers: RedTea, ColaIan", description="Multi-purpose Discord Bot",
7676
color=0x7400FF)
7777
embed.set_author(name=f"Teapot.py {teapot.version()}",
7878
icon_url="https://cdn.discordapp.com/avatars/612634758744113182/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
@@ -102,6 +102,7 @@ def ping(bot):
102102
@bot.command()
103103
async def ping(ctx):
104104
await ctx.send(f'Pong! {round(bot.latency * 1000)} ms')
105+
await ctx.message.add_reaction(emoji='✅')
105106

106107

107108
def prune(bot):
@@ -110,13 +111,18 @@ def prune(bot):
110111
async def prune(ctx, amount=0):
111112
if amount == 0:
112113
await ctx.send("Please specify the number of messages you want to delete!")
114+
await ctx.message.add_reaction(emoji='❌')
115+
elif amount <= 0: # lower then 0
116+
await ctx.send("The number must be bigger than 0!")
117+
await ctx.message.add_reaction(emoji='❌')
113118
else:
119+
await ctx.message.add_reaction(emoji='✅')
114120
await ctx.channel.purge(limit=amount + 1)
115121

116122

117123
def kick(bot):
118124
@bot.command()
119-
@cmd.has_permissions(kick_members=True)
125+
@cmd.has_permissions(kick_members=True) # check user permission
120126
async def kick(ctx, member: discord.Member, *, reason=None):
121127
try:
122128
await member.kick(reason=reason)

teapot/cogs/github.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self, bot):
1717
@commands.command(pass_context=True, aliases=['gh'])
1818
async def github(self, ctx, arg):
1919
"""Fetch repository info"""
20+
2021
req = requests.get(f'https://api.github.com/repos/{arg}')
2122
apijson = json.loads(req.text)
2223
if req.status_code == 200:
@@ -50,9 +51,15 @@ async def github(self, ctx, arg):
5051

5152
await ctx.send(embed=em)
5253
elif req.status_code == 404:
54+
"""if repository not found"""
5355
await ctx.send(embed=teapot.messages.notfound("repository"))
56+
elif req.status_code == 503:
57+
"""GithubAPI down"""
58+
await ctx.send("GithubAPI down")
59+
await ctx.send(embed=teapot.messages.notfound("Fetch repository info"))
5460
else:
55-
await ctx.send(embed=teapot.messages.error("repository"))
61+
"""some error occurred while fetching repository info"""
62+
await ctx.send(embed=teapot.messages.error("Fetch repository info"))
5663

5764

5865
def setup(bot):

teapot/cogs/music.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def connect_to(self, guild_id: int, channel_id: str):
5151
@commands.command(aliases=['p'])
5252
async def play(self, ctx, *, query: str):
5353
""" Searches and plays a song from a given query. """
54-
player = self.bot.lavalink.players.get(ctx.guild.id)
54+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
5555

5656
query = query.strip('<>')
5757

@@ -87,7 +87,7 @@ async def play(self, ctx, *, query: str):
8787
@commands.command()
8888
async def seek(self, ctx, *, seconds: int):
8989
""" Seeks to a given position in a track. """
90-
player = self.bot.lavalink.players.get(ctx.guild.id)
90+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
9191

9292
track_time = player.position + (seconds * 1000)
9393
await player.seek(track_time)
@@ -97,7 +97,7 @@ async def seek(self, ctx, *, seconds: int):
9797
@commands.command(aliases=['forceskip'])
9898
async def skip(self, ctx):
9999
""" Skips the current track. """
100-
player = self.bot.lavalink.players.get(ctx.guild.id)
100+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
101101

102102
if not player.is_playing:
103103
return await ctx.send('Not playing.')
@@ -108,7 +108,7 @@ async def skip(self, ctx):
108108
@commands.command()
109109
async def stop(self, ctx):
110110
""" Stops the player and clears its queue. """
111-
player = self.bot.lavalink.players.get(ctx.guild.id)
111+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
112112

113113
if not player.is_playing:
114114
return await ctx.send('Not playing.')
@@ -120,7 +120,7 @@ async def stop(self, ctx):
120120
@commands.command(aliases=['np', 'n', 'playing'])
121121
async def now(self, ctx):
122122
""" Shows some stats about the currently playing song. """
123-
player = self.bot.lavalink.players.get(ctx.guild.id)
123+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
124124

125125
if not player.current:
126126
return await ctx.send('Nothing playing.')
@@ -139,7 +139,7 @@ async def now(self, ctx):
139139
@commands.command(aliases=['q'])
140140
async def queue(self, ctx, page: int = 1):
141141
""" Shows the player's queue. """
142-
player = self.bot.lavalink.players.get(ctx.guild.id)
142+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
143143

144144
if not player.queue:
145145
return await ctx.send('Nothing queued.')
@@ -162,7 +162,7 @@ async def queue(self, ctx, page: int = 1):
162162
@commands.command(aliases=['resume'])
163163
async def pause(self, ctx):
164164
""" Pauses/Resumes the current track. """
165-
player = self.bot.lavalink.players.get(ctx.guild.id)
165+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
166166

167167
if not player.is_playing:
168168
return await ctx.send('Not playing.')
@@ -177,7 +177,7 @@ async def pause(self, ctx):
177177
@commands.command(aliases=['vol'])
178178
async def volume(self, ctx, volume):
179179
""" Changes the player's volume (0-1000). """
180-
player = self.bot.lavalink.players.get(ctx.guild.id)
180+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
181181

182182
try:
183183
volume = int(volume)
@@ -193,7 +193,7 @@ async def volume(self, ctx, volume):
193193
@commands.command()
194194
async def shuffle(self, ctx):
195195
""" Shuffles the player's queue. """
196-
player = self.bot.lavalink.players.get(ctx.guild.id)
196+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
197197
if not player.is_playing:
198198
return await ctx.send('Nothing playing.')
199199

@@ -203,7 +203,7 @@ async def shuffle(self, ctx):
203203
@commands.command(aliases=['loop', 'l'])
204204
async def repeat(self, ctx):
205205
""" Repeats the current song until the command is invoked again. """
206-
player = self.bot.lavalink.players.get(ctx.guild.id)
206+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
207207

208208
if not player.is_playing:
209209
return await ctx.send('Nothing playing.')
@@ -214,7 +214,7 @@ async def repeat(self, ctx):
214214
@commands.command()
215215
async def remove(self, ctx, index: int):
216216
""" Removes an item from the player's queue with the given index. """
217-
player = self.bot.lavalink.players.get(ctx.guild.id)
217+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
218218

219219
if not player.queue:
220220
return await ctx.send('Nothing queued.')
@@ -229,7 +229,7 @@ async def remove(self, ctx, index: int):
229229
@commands.command()
230230
async def find(self, ctx, *, query):
231231
""" Lists the first 10 search results from a given query. """
232-
player = self.bot.lavalink.players.get(ctx.guild.id)
232+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
233233

234234
if not query.startswith('ytsearch:') and not query.startswith('scsearch:'):
235235
query = 'ytsearch:' + query
@@ -253,7 +253,7 @@ async def find(self, ctx, *, query):
253253
@commands.command(aliases=['dc'])
254254
async def disconnect(self, ctx):
255255
""" Disconnects the player from the voice channel and clears its queue. """
256-
player = self.bot.lavalink.players.get(ctx.guild.id)
256+
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
257257

258258
if not player.is_connected:
259259
return await ctx.send('Not connected.')
@@ -268,9 +268,7 @@ async def disconnect(self, ctx):
268268

269269
async def ensure_voice(self, ctx):
270270
""" This check ensures that the bot and command author are in the same voice channel. """
271-
player = self.bot.lavalink.players.create(ctx.guild.id, endpoint=str(ctx.guild.region))
272-
# Create returns a player if one exists, otherwise creates.
273-
271+
player = self.bot.lavalink.player_manager.create(ctx.guild.id, endpoint=str(ctx.guild.region))
274272
should_connect = ctx.command.name in ('play') # Add commands that require joining voice to work.
275273

276274
if not ctx.author.voice or not ctx.author.voice.channel:

teapot/cogs/osu.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ async def osu(self, ctx, *, args: str):
6464
type = "0"
6565
else:
6666
await ctx.send('Invalid Syntax!')
67+
await ctx.message.add_reaction(emoji='❌')
6768
return
6869
cookiezi = '05b43eb66b2977d4f2c9148b00e3853688d515cf'
6970
r = requests.get('http://osu.ppy.sh/api/get_user?k=' + cookiezi + '&u=' + peppy + '&m=' + type)
@@ -72,6 +73,7 @@ async def osu(self, ctx, *, args: str):
7273
print('Unable to fetch osu statistics!')
7374
return
7475

76+
await ctx.message.add_reaction(emoji='✅')
7577
await ctx.send(embed=OsuPlayer(json.loads(r.text)[0]).display(ctx.message.author))
7678

7779

teapot/messages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33

44
def WIP():
5+
"""Work In Progress"""
56
return discord.Embed(title="⏲ This feature is work in progress!",
67
description="Please stay tuned to our latest updates [here]("
78
"https://github.com/RedCokeDevelopment/Teapot.py)!", color=0x89CFF0)
89

910

1011
def PermissionDenied():
12+
"""user don't have permission"""
1113
return discord.Embed(title="🛑 Permission Denied!", description="You do not have permission to do this!",
1214
color=0xFF0000)
1315

0 commit comments

Comments
 (0)