switched all messaging to embeds
This commit is contained in:
parent
695bcb391c
commit
531cc76446
14
src/embed.py
14
src/embed.py
@ -2,8 +2,8 @@ import discord
|
|||||||
from pytube import YouTube
|
from pytube import YouTube
|
||||||
|
|
||||||
def get_status(channel, queue, playing):
|
def get_status(channel, queue, playing):
|
||||||
desc = 'playing {0} in {1}'.format(playing, channel)
|
desc = 'playing {0} in {1}'.format(playing.title, channel)
|
||||||
emb = discord.Embed(title='music-bot', description=desc,color=0x00FF00)
|
emb = discord.Embed(title='music-bot', description=desc,color=0x0000FF)
|
||||||
lst = ""
|
lst = ""
|
||||||
for i in range(0, min(10, queue.num_remaining())):
|
for i in range(0, min(10, queue.num_remaining())):
|
||||||
title = queue.elem[i].title
|
title = queue.elem[i].title
|
||||||
@ -11,5 +11,13 @@ def get_status(channel, queue, playing):
|
|||||||
if lst == "":
|
if lst == "":
|
||||||
lst = "empty queue"
|
lst = "empty queue"
|
||||||
emb.add_field(name="next up: ", value=lst)
|
emb.add_field(name="next up: ", value=lst)
|
||||||
|
emb.set_thumbnail(url=playing.thumbnail_url)
|
||||||
return emb
|
return emb
|
||||||
|
|
||||||
|
def get_error(message):
|
||||||
|
emb = discord.Embed(title='music-bot', description=message,color=0xFF0000)
|
||||||
|
return emb
|
||||||
|
|
||||||
|
def get_success(message):
|
||||||
|
emb = discord.Embed(title='music-bot', description=message,color=0x00FF00)
|
||||||
|
return emb
|
@ -2,7 +2,7 @@ import asyncio
|
|||||||
from config import *
|
from config import *
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from embed import get_status
|
from embed import *
|
||||||
from pytube import YouTube, Playlist
|
from pytube import YouTube, Playlist
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ async def on_ready():
|
|||||||
@bot.command()
|
@bot.command()
|
||||||
async def setprefix(ctx, *arg):
|
async def setprefix(ctx, *arg):
|
||||||
if(len(arg) != 1):
|
if(len(arg) != 1):
|
||||||
await ctx.send("usage: setprefix <prefix>")
|
await ctx.send(embed=get_error("usage: setprefix <prefix>"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
prefix = arg[0]
|
prefix = arg[0]
|
||||||
@ -46,12 +46,12 @@ async def setprefix(ctx, *arg):
|
|||||||
bot.config['guild']['prefix'] = prefix
|
bot.config['guild']['prefix'] = prefix
|
||||||
save_config(config_path, bot.config)
|
save_config(config_path, bot.config)
|
||||||
|
|
||||||
await ctx.send("set prefix to: {0}".format(prefix))
|
await ctx.send(embed=get_success("set prefix to: {0}".format(prefix)))
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def setrole(ctx, *arg: discord.Role):
|
async def setrole(ctx, *arg: discord.Role):
|
||||||
if(len(arg) != 1):
|
if(len(arg) != 1):
|
||||||
await ctx.send("usage: setrole @<rolename>")
|
await ctx.send(embed=get_error("usage: setrole @<rolename>"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
roleid = arg[0].id
|
roleid = arg[0].id
|
||||||
@ -59,7 +59,7 @@ async def setrole(ctx, *arg: discord.Role):
|
|||||||
bot.config['guild']['roleid'] = roleid
|
bot.config['guild']['roleid'] = roleid
|
||||||
save_config(config_path, bot.config)
|
save_config(config_path, bot.config)
|
||||||
|
|
||||||
await ctx.send("set playable role to {0}".format(arg[0]))
|
await ctx.send(embed=get_success("set playable role to {0}".format(arg[0])))
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def leave(ctx):
|
async def leave(ctx):
|
||||||
@ -79,13 +79,13 @@ async def shuffle(ctx):
|
|||||||
roleid = bot.config['guild']['roleid']
|
roleid = bot.config['guild']['roleid']
|
||||||
|
|
||||||
if(ctx.author.voice == None):
|
if(ctx.author.voice == None):
|
||||||
await ctx.send("you are not in a voice channel")
|
await ctx.send(embed=get_error("you are not in a voice channel"))
|
||||||
return
|
return
|
||||||
elif(roleid not in [role.id for role in ctx.author.roles]):
|
elif(roleid not in [role.id for role in ctx.author.roles]):
|
||||||
await ctx.send("you do not have the role to play music")
|
await ctx.send(embed=get_error("you do not have the role to play music"))
|
||||||
return
|
return
|
||||||
elif(not ctx.voice_client.is_connected()):
|
elif(not ctx.voice_client.is_connected()):
|
||||||
await ctx.send("bot is not connected to a voice channel")
|
await ctx.send(embed=get_error("bot is not connected to a voice channel"))
|
||||||
else:
|
else:
|
||||||
bot.queue.shuffle()
|
bot.queue.shuffle()
|
||||||
await ctx.send(embed=get_status(ctx.voice_client.channel, bot.queue, bot.currently_playing))
|
await ctx.send(embed=get_status(ctx.voice_client.channel, bot.queue, bot.currently_playing))
|
||||||
@ -97,22 +97,22 @@ async def play(ctx, *arg):
|
|||||||
prefix = bot.config['guild']['prefix']
|
prefix = bot.config['guild']['prefix']
|
||||||
|
|
||||||
if(len(arg) != 1):
|
if(len(arg) != 1):
|
||||||
await ctx.send("usage: play <YouTube url>")
|
await ctx.send(embed=get_error("usage: play <YouTube url>"))
|
||||||
return
|
return
|
||||||
elif(ctx.author.voice == None):
|
elif(ctx.author.voice == None):
|
||||||
await ctx.send("you are not in a voice channel")
|
await ctx.send(embed=get_error("you are not in a voice channel"))
|
||||||
return
|
return
|
||||||
elif(roleid not in [role.id for role in ctx.author.roles]):
|
elif(roleid not in [role.id for role in ctx.author.roles]):
|
||||||
await ctx.send("you do not have the role to play music")
|
await ctx.send(embed=get_error("you do not have the role to play music"))
|
||||||
return
|
return
|
||||||
|
|
||||||
if(ctx.voice_client == None): # if not in vc, join
|
if(ctx.voice_client == None): # if not in vc, join
|
||||||
channel = ctx.message.author.voice.channel
|
channel = ctx.message.author.voice.channel
|
||||||
await ctx.send(f'Connected to ``{channel}``')
|
await ctx.send(embed=get_success('Connected to ``{0}``'.format(channel)))
|
||||||
await channel.connect()
|
await channel.connect()
|
||||||
bot.queue.random = False
|
bot.queue.random = False
|
||||||
elif (ctx.voice_client.channel != ctx.author.voice.channel): # if in another vc than author, ignore
|
elif (ctx.voice_client.channel != ctx.author.voice.channel): # if in another vc than author, ignore
|
||||||
await ctx.send("bot already connected to another channel, use {0}leave".format(prefix))
|
await ctx.send(embed=get_error("bot already connected to another channel, use {0}leave".format(prefix)))
|
||||||
return
|
return
|
||||||
|
|
||||||
url = arg[0]
|
url = arg[0]
|
||||||
@ -125,11 +125,11 @@ async def play(ctx, *arg):
|
|||||||
yt = YouTube(video)
|
yt = YouTube(video)
|
||||||
bot.queue.enqueue(yt)
|
bot.queue.enqueue(yt)
|
||||||
count += 1
|
count += 1
|
||||||
await ctx.send('added {0} tracks to queue'.format(len(pl)))
|
await ctx.send(embed=get_success('added {0} tracks to queue'.format(len(pl))))
|
||||||
else:
|
else:
|
||||||
yt = YouTube(url)
|
yt = YouTube(url)
|
||||||
bot.queue.enqueue(yt)
|
bot.queue.enqueue(yt)
|
||||||
await ctx.send('added {0} to queue'.format(yt.title))
|
await ctx.send(embed=get_success('added {0} to queue'.format(yt.title)))
|
||||||
|
|
||||||
if(ctx.voice_client.is_playing()):
|
if(ctx.voice_client.is_playing()):
|
||||||
pass
|
pass
|
||||||
@ -149,7 +149,7 @@ async def start_playing(ctx): # should guarantee ctx.voice_client.is_playing() i
|
|||||||
name = yt.title
|
name = yt.title
|
||||||
duration = yt.length
|
duration = yt.length
|
||||||
|
|
||||||
bot.currently_playing = name
|
bot.currently_playing = yt
|
||||||
|
|
||||||
filepath = 'session/'
|
filepath = 'session/'
|
||||||
fileprefix = ''
|
fileprefix = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user