Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

Commit 7ccf2be

Browse files
author
Benjamin O'Brien
committed
Join, Leave, Stop & De/Encrypt
1 parent 0f22814 commit 7ccf2be

File tree

8 files changed

+239
-5
lines changed

8 files changed

+239
-5
lines changed

commands/entertainment/decrypt.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Modules
2+
import base64
3+
import discord
4+
5+
from assets.prism import Tools
6+
from discord.ext import commands
7+
8+
# Main Command Class
9+
class Decrypt(commands.Cog):
10+
11+
def __init__(self, bot):
12+
self.bot = bot
13+
self.desc = "Decrypt some text using the base64 format."
14+
self.usage = "decrypt [text]"
15+
16+
@commands.command()
17+
async def decrypt(self, ctx, *, text: str = None):
18+
19+
if not text:
20+
21+
return await ctx.send(embed = Tools.error("No text specified to decrypt."))
22+
23+
try:
24+
25+
encrypted = base64.b64decode(text.encode("ascii")).decode("ascii")
26+
27+
except:
28+
29+
return await ctx.send(embed = Tools.error("Sorry, your text couldn't be decrypted."))
30+
31+
embed = discord.Embed(title = "Decryption Results", description = f"```\n{encrypted}\n```", color = 0x126bf1)
32+
33+
embed.set_author(name = " | Decrypt", icon_url = self.bot.user.avatar_url)
34+
35+
embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url)
36+
37+
try:
38+
39+
return await ctx.send(embed = embed)
40+
41+
except:
42+
43+
return await ctx.send(embed = Tools.error("Failed to send the embed, check your text."))
44+
45+
# Link to bot
46+
def setup(bot):
47+
bot.add_cog(Decrypt(bot))

commands/entertainment/encrypt.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Modules
2+
import base64
3+
import discord
4+
5+
from assets.prism import Tools
6+
from discord.ext import commands
7+
8+
# Main Command Class
9+
class Encrypt(commands.Cog):
10+
11+
def __init__(self, bot):
12+
self.bot = bot
13+
self.desc = "Encrypts some text using the base64 format."
14+
self.usage = "encrypt [text]"
15+
16+
@commands.command()
17+
async def encrypt(self, ctx, *, text: str = None):
18+
19+
if not text:
20+
21+
return await ctx.send(embed = Tools.error("No text specified to encrypt."))
22+
23+
elif len(text) > 200:
24+
25+
return await ctx.send(embed = Tools.error("Text is too long, it should be 200 at max."))
26+
27+
try:
28+
29+
encrypted = base64.b64encode(text.encode("ascii")).decode("ascii")
30+
31+
except:
32+
33+
return await ctx.send(embed = Tools.error("Sorry, your text couldn't be encrypted."))
34+
35+
embed = discord.Embed(title = "Encryption Results", description = f"```\n{encrypted}\n```", color = 0x126bf1)
36+
37+
embed.set_author(name = " | Encrypt", icon_url = self.bot.user.avatar_url)
38+
39+
embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url)
40+
41+
try:
42+
43+
return await ctx.send(embed = embed)
44+
45+
except:
46+
47+
return await ctx.send(embed = Tools.error("Failed to send the embed, check your text."))
48+
49+
# Link to bot
50+
def setup(bot):
51+
bot.add_cog(Encrypt(bot))

commands/misc/bio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ async def biography(self, ctx, *, bio: str = None):
2020

2121
return await ctx.send(embed = Tools.error("Please specify a biography."))
2222

23-
elif len(bio) > 200:
23+
elif len(bio) > 40:
2424

25-
return await ctx.send(embed = Tools.error("You're biography is way too long."))
25+
return await ctx.send(embed = Tools.error("You're biography is way too long (40 characters max)."))
2626

2727
db = json.loads(open("db/users", "r").read())
2828

commands/misc/card.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ def font(size, font = "Thin"):
4646

4747
draw.text((450, 10), f"{ctx.author.name}#{ctx.author.discriminator}", font = font(200, "Regular"), fill = (255, 255, 255))
4848

49-
draw.line((0, 425) + (3000, 425), fill = (255, 255, 255))
49+
draw.line((10, 425) + (3000, 425), fill = (255, 255, 255), width = 10)
5050

51-
draw.text((450, 225), f"Level {user['data']['levels']['level']}", font = font(150), fill = (255, 255, 255))
51+
draw.text((450, 225), f"Level {user['data']['levels']['level']}", font = font(150), fill = (225, 225, 225))
52+
53+
draw.text((10, 450), f"\"{user['data']['bio']}\"", font = font(125), fill = (255, 255, 255))
5254

5355
# Package the image
5456
imgByteArr = BytesIO()

commands/music/join.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Modules
2+
import discord
3+
from assets.prism import Tools
4+
5+
from discord.ext import commands
6+
7+
# Main Command Class
8+
class Join(commands.Cog):
9+
10+
def __init__(self, bot):
11+
self.bot = bot
12+
self.desc = "Connects to your voice channel."
13+
self.usage = "join"
14+
15+
@commands.command(aliases = ["connect"])
16+
async def join(self, ctx):
17+
18+
if not ctx.author.voice:
19+
20+
return await ctx.send(embed = Tools.error("You aren't in a voice channel."))
21+
22+
voice = discord.utils.get(self.bot.voice_clients, guild = ctx.guild)
23+
24+
if voice:
25+
26+
await voice.move_to(ctx.author.voice.channel)
27+
28+
return await ctx.send(embed = discord.Embed(description = f":wave: **Moved to #{ctx.author.voice.channel.name}.**", color = 0x126bf1))
29+
30+
else:
31+
32+
await ctx.author.voice.channel.connect()
33+
34+
return await ctx.send(embed = discord.Embed(description = f":wave: **Connected to #{ctx.author.voice.channel.name}.**", color = 0x126bf1))
35+
36+
# Link to bot
37+
def setup(bot):
38+
bot.add_cog(Join(bot))

commands/music/leave.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Modules
2+
import discord
3+
from assets.prism import Tools
4+
5+
from discord.ext import commands
6+
7+
# Main Command Class
8+
class Leave(commands.Cog):
9+
10+
def __init__(self, bot):
11+
self.bot = bot
12+
self.desc = "Makes Prism leave your voice channel."
13+
self.usage = "leave"
14+
15+
@commands.command(aliases = ["disconnect", "dsc", "fuckoff"])
16+
async def leave(self, ctx):
17+
18+
if not ctx.author.voice:
19+
20+
return await ctx.send(embed = Tools.error("You aren't in a voice channel."))
21+
22+
voice = discord.utils.get(self.bot.voice_clients, guild = ctx.guild)
23+
24+
if not voice:
25+
26+
return await ctx.send(embed = Tools.error("Prism isn't in a voice channel."))
27+
28+
elif voice.is_playing():
29+
30+
try:
31+
32+
voice.stop()
33+
34+
except:
35+
36+
pass
37+
38+
await voice.disconnect()
39+
40+
return await ctx.send(embed = discord.Embed(description = f":wave: **Left the voice channel.**", color = 0x126bf1))
41+
42+
# Link to bot
43+
def setup(bot):
44+
bot.add_cog(Leave(bot))

commands/music/play.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ async def play(self, ctx, url: str = None):
3030

3131
voice = await ctx.author.voice.channel.connect()
3232

33+
elif voice.is_playing():
34+
35+
voice.stop()
36+
3337
with youtube_dl.YoutubeDL({}) as ytdl:
3438

3539
info = ytdl.extract_info(url, download = False)
@@ -40,7 +44,11 @@ async def play(self, ctx, url: str = None):
4044

4145
voice.source.volume = 1
4246

43-
return await ctx.send(embed = discord.Embed(description = f":musical_note: **Now playing: {info['title']}**", color = 0x126bf1))
47+
embed = discord.Embed(description = f":musical_note: **Now playing: {info['title']}**", color = 0x126bf1)
48+
49+
embed.set_footer(text = " | Please note: music is experimental, freezing may occur.", icon_url = ctx.author.avatar_url)
50+
51+
return await ctx.send(embed = embed)
4452

4553
# Link to bot
4654
def setup(bot):

commands/music/stop.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Modules
2+
import discord
3+
4+
from assets.prism import Tools
5+
from discord.ext import commands
6+
7+
# Main Command Class
8+
class Stop(commands.Cog):
9+
10+
def __init__(self, bot):
11+
self.bot = bot
12+
self.desc = "Stops playing music in your voice channel."
13+
self.usage = "stop"
14+
15+
@commands.command()
16+
async def stop(self, ctx):
17+
18+
if not ctx.author.voice:
19+
20+
return await ctx.send(embed = Tools.error("You aren't in a voice channel."))
21+
22+
voice = discord.utils.get(self.bot.voice_clients, guild = ctx.guild)
23+
24+
if not voice:
25+
26+
return await ctx.send(embed = Tools.error("Prism isn't in a voice channel."))
27+
28+
elif not voice.is_playing():
29+
30+
return await ctx.send(embed = Tools.error("No music is currently playing."))
31+
32+
try:
33+
34+
voice.stop()
35+
36+
except:
37+
38+
return await ctx.send(embed = Tools.error("Something went wrong while stopping."))
39+
40+
return await ctx.send(embed = discord.Embed(description = f":x: **Playback stopped.**", color = 0x126bf1))
41+
42+
# Link to bot
43+
def setup(bot):
44+
bot.add_cog(Stop(bot))

0 commit comments

Comments
 (0)