Browse Source

Made an enumertator for the embed colours so that it is standardised and easier to manage.

tags/v1.7.0
Roxie Gibson 6 years ago
parent
commit
db77ed9692
12 changed files with 44 additions and 31 deletions
  1. +1
    -1
      Roxbot/cogs/admin.py
  2. +1
    -1
      Roxbot/cogs/customcommands.py
  3. +1
    -1
      Roxbot/cogs/fun.py
  4. +3
    -2
      Roxbot/cogs/joinleave.py
  5. +4
    -5
      Roxbot/cogs/selfassign.py
  6. +5
    -6
      Roxbot/cogs/trivia.py
  7. +6
    -3
      Roxbot/cogs/voice.py
  8. +4
    -4
      Roxbot/err_handle.py
  9. +12
    -1
      Roxbot/load_config.py
  10. +4
    -4
      Roxbot/logging.py
  11. +2
    -2
      Roxbot/settings/settings.py
  12. +1
    -1
      main.py

+ 1
- 1
Roxbot/cogs/admin.py View File

@@ -155,7 +155,7 @@ class Admin():
if user_id not in settings.warnings:
return await ctx.send("This user doesn't have any warning on record.")

em = discord.Embed(title="Warnings for {}".format(str(user)), colour=0XDEADBF)
em = discord.Embed(title="Warnings for {}".format(str(user)), colour=roxbot.EmbedColours.pink)
em.set_thumbnail(url=user.avatar_url)
x = 1
userlist = settings.warnings[user_id]

+ 1
- 1
Roxbot/cogs/customcommands.py View File

@@ -123,7 +123,7 @@ class CustomCommands():

# TODO: Sort out a way to shorten this if it goes over 2000 characters.
em = discord.Embed(title="Here is the list of Custom Commands", color=Roxbot.embedcolour)
em = discord.Embed(title="Here is the list of Custom Commands", color=Roxbot.EmbedColours.pink)
em.add_field(name="Commands that require Prefix:", value=listone, inline=False)
em.add_field(name="Commands that don't:", value=listzero, inline=False)
return await ctx.send(embed=em)

+ 1
- 1
Roxbot/cogs/fun.py View File

@@ -253,7 +253,7 @@ class Fun:
endpoint = "https://frog.tips/api/1/tips/"
croak = await Roxbot.http.api_request(endpoint)
tip = random.choice(croak["tips"])
embed = discord.Embed(title="Frog Tip #{}".format(tip["number"]), description=tip["tip"], colour=discord.Colour(0x4C943D))
embed = discord.Embed(title="Frog Tip #{}".format(tip["number"]), description=tip["tip"], colour=Roxbot.EmbedColours.frog_green)
embed.set_author(name="HOW TO OPERATE YOUR FROG")
embed.set_footer(text="https://frog.tips")
return await ctx.send(embed=embed)

+ 3
- 2
Roxbot/cogs/joinleave.py View File

@@ -1,4 +1,5 @@
import discord
import Roxbot
from Roxbot import guild_settings


@@ -21,7 +22,7 @@ class JoinLeave():
em = discord.Embed(
title="Welcome to {}!".format(member.guild),
description='Hey {}! Welcome to **{}**! {}'.format(member.mention, member.guild, message),
colour=0xDEADBF)
colour=Roxbot.EmbedColours.pink)
em.set_thumbnail(url=member.avatar_url)

channel = self.bot.get_channel(settings.greets["welcome-channel"])
@@ -38,7 +39,7 @@ class JoinLeave():
else:
channel = self.bot.get_channel(channel)
return await channel.send(embed=discord.Embed(
description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=0xDEADBF))
description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=Roxbot.EmbedColours.pink))


def setup(Bot):

+ 4
- 5
Roxbot/cogs/selfassign.py View File

@@ -8,7 +8,6 @@ from Roxbot import guild_settings as gs
class SelfAssign():
def __init__(self, Bot):
self.bot = Bot
self.embed_colour = Roxbot.embedcolour

@commands.command(pass_context=True)
async def listroles(self, ctx):
@@ -19,7 +18,7 @@ class SelfAssign():
"""
settings = gs.get(ctx.guild)
if not settings.self_assign["enabled"]:
embed = discord.Embed(colour=discord.Colour(self.embed_colour), description="SelfAssignable roles are not enabled on this server")
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
return await ctx.send(embed=embed)
roles = []
for role in settings.self_assign["roles"]:
@@ -27,7 +26,7 @@ class SelfAssign():
if role == serverrole.id:
roles.append("**"+serverrole.name+"**")
roles = '\n'.join(roles)
embed = discord.Embed(colour=self.embed_colour, description="The self-assignable roles for this server are: \n"+roles)
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="The self-assignable roles for this server are: \n"+roles)
return await ctx.send(embed=embed)

@commands.command(pass_context=True)
@@ -47,7 +46,7 @@ class SelfAssign():
raise commands.MissingRequiredArgument(Parameter("Role", False))

if not settings.self_assign["enabled"]:
embed = discord.Embed(colour=discord.Colour(self.embed_colour), description="SelfAssignable roles are not enabled on this server")
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
return await ctx.send(embed=embed)

member = ctx.author
@@ -77,7 +76,7 @@ class SelfAssign():
raise commands.MissingRequiredArgument(Parameter("role", False))

if not settings.self_assign["enabled"]:
embed = discord.Embed(colour=discord.Colour(self.embed_colour), description="SelfAssignable roles are not enabled on this server")
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
return await ctx.send(embed=embed)

member = ctx.author

+ 5
- 6
Roxbot/cogs/trivia.py View File

@@ -8,8 +8,7 @@ from random import shuffle
from collections import OrderedDict
from discord.ext import commands

from Roxbot import http
from Roxbot import checks
from Roxbot import http, checks, EmbedColours


class Trivia:
@@ -29,8 +28,8 @@ class Trivia:
self.incorrect_emoji = self.bot.get_emoji(421526796379488256)
self.emojis = [a_emoji, b_emoji, c_emoji, d_emoji]
self.games = {}
self.error_colour = 0x992d22
self.trivia_colour = 0x6f90f5
self.error_colour = EmbedColours.dark_red
self.trivia_colour = EmbedColours.blue

# Game Functions

@@ -216,7 +215,7 @@ class Trivia:
async def trivia(self, ctx):
"""Command group for the Roxbot Trivia game."""
if ctx.invoked_subcommand == self.start and ctx.channel.id not in self.games:
embed = discord.Embed(colour=0xDEADBF)
embed = discord.Embed(colour=EmbedColours.pink)
embed.set_footer(text="Roxbot Trivia uses the Open Trivia DB, made and maintained by Pixeltail Games LLC. Find out more at https://opentdb.com/")
embed.set_image(url="https://i.imgur.com/yhRVl9e.png")
await ctx.send(embed=embed)
@@ -229,7 +228,7 @@ class Trivia:
embed = discord.Embed(
title="About Roxbot Trivia",
description="Roxbot Trivia is a trivia game in *your* discord server. It's heavily inspired by Tower Unite's trivia game. (and even uses the same questions database!) To start, just type `{}trivia start`.".format(self.bot.command_prefix),
colour=0xDEADBF)
colour=EmbedColours.pink)
embed.add_field(name="How to Play", value="Once the game has started, questions will be asked and you will be given 20 seconds to answer them. To answer, react with the corrosponding emoji. Roxbot will only accept your first answer. Score is calculated by how quickly you can answer correctly, so make sure to be as quick as possible to win! Person with the most score at the end wins. Glhf!")
embed.add_field(name="Can I have shorter or longer games?", value="Yes! You can change the length of the game by adding either short (5 questions) or long (15 questions) at the end of the start command. `{}trivia start short`. The default is 10 and this is the medium option.".format(self.bot.command_prefix))
embed.add_field(name="Can I play with friends?", value="Yes! Trivia is best with friends. How else would friendships come to their untimely demise? You can only join a game during the 20 second waiting period after a game is started. Just type `{0}trivia join` and you're in! You can leave a game at anytime (even if its just you) by doing `{0}trivia leave`. If no players are in a game, the game will end and no one will win ;-;".format(self.bot.command_prefix))

+ 6
- 3
Roxbot/cogs/voice.py View File

@@ -121,6 +121,7 @@ class Voice:
self.queue_logic[guild.id] = None

async def _queue_logic(self, ctx):
# TODO: This is broke it seems.
"""Background task designed to help the bot move on to the next video in the queue"""
if ctx.voice_client.source == self.now_playing[ctx.guild.id]:
sleep_for = 0.5
@@ -148,6 +149,7 @@ class Voice:
return video

def _format_duration(self, duration):
# TODO: Fix when duration returns nothing and the bot breaks here.
hours = duration // 3600
minutes = (duration % 3600) // 60
seconds = duration % 60
@@ -164,7 +166,7 @@ class Voice:
duration = self._format_duration(np.duration)
time_played = self._format_duration(np.source.timer/1000)

embed = discord.Embed(title=title, colour=0xDEADBF, url=np.webpage_url)
embed = discord.Embed(title=title, colour=Roxbot.EmbedColours.pink, url=np.webpage_url)
embed.description = "Uploaded by: [{0.uploader}]({0.uploader_url})\nURL: [Here]({0.webpage_url})\nDuration: {1}\nQueued by: {0.queued_by}".format(np, duration)
embed.set_image(url=np.thumbnail_url)
embed.set_footer(text="Timer: {}/{}".format(time_played, duration))
@@ -266,7 +268,7 @@ class Voice:
# Sleep because if not, queued up things will send first and probably freak out users or something
while self.am_queuing[guild.id] is True:
await asyncio.sleep(0.5)
embed = discord.Embed(description='Added "{}" to queue'.format(video.get("title")), colour=0xDEADBF)
embed = discord.Embed(description='Added "{}" to queue'.format(video.get("title")), colour=Roxbot.EmbedColours.pink)
await ctx.send(embed=embed)

@commands.cooldown(1, 0.5, commands.BucketType.guild)
@@ -346,6 +348,7 @@ class Voice:

@commands.command()
async def skip(self, ctx, option=""):
# TODO: Skipping isn't cleaned properly when successful
"""Skips or votes to skip the current video. Use option "--force" if your an admin and """
voice = guild_settings.get(ctx.guild).voice
if ctx.voice_client.is_playing():
@@ -397,7 +400,7 @@ class Voice:
index += 1
if output == "":
output = "Nothing is up next. Maybe you should add something!"
embed = discord.Embed(title="Queue", description=output, colour=0xDEADBF)
embed = discord.Embed(title="Queue", description=output, colour=Roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)

@Roxbot.checks.is_admin_or_mod()

+ 4
- 4
Roxbot/err_handle.py View File

@@ -3,6 +3,7 @@ import discord
import datetime
import traceback
from discord.ext import commands
import Roxbot
from Roxbot import guild_settings


@@ -15,7 +16,7 @@ class ErrHandle:
if self.dev:
traceback.print_exc()
else:
embed = discord.Embed(title="Roxbot Error", colour=0xe74c3c) # Red
embed = discord.Embed(title="Roxbot Error", colour=Roxbot.EmbedColours.red) # Red
embed.add_field(name='Event', value=event)
embed.description = '```py\n{}\n```'.format(traceback.format_exc())
embed.timestamp = datetime.datetime.utcnow()
@@ -23,11 +24,10 @@ class ErrHandle:

async def on_command_error(self, ctx, error):
self.owner = self.bot.get_user(self.bot.owner_id)
err_colour = 0x992d22
if self.dev:
raise error
elif isinstance(error, commands.CommandInvokeError):
embed = discord.Embed(title='Command Error', colour=err_colour)
embed = discord.Embed(title='Command Error', colour=Roxbot.EmbedColours.dark_red)
embed.description = str(error)
embed.add_field(name='Server', value=ctx.guild)
embed.add_field(name='Channel', value=ctx.channel.mention)
@@ -71,7 +71,7 @@ class ErrHandle:
embed = discord.Embed(
description="Placeholder embed. If you see this please message {}.".format(str(self.owner)))
if embed:
embed.colour = err_colour
embed.colour = Roxbot.EmbedColours.dark_red
await ctx.send(embed=embed, delete_after=8)



+ 12
- 1
Roxbot/load_config.py View File

@@ -1,5 +1,7 @@
from enum import Enum
import configparser


settings = configparser.ConfigParser()
settings.read("Roxbot/settings/preferences.ini")

@@ -7,7 +9,16 @@ command_prefix = settings["Roxbot"]["Command_Prefix"]
token = settings["Roxbot"]["Token"]
owner = int(settings["Roxbot"]["OwnerID"])
tat_token = settings["Roxbot"]["Tatsumaki_Token"]
embedcolour = 0xDEADBF


class EmbedColours(Enum):
pink = 0xDEADBF
yellow = 0xFDDF86
blue = 0x6F90F5
frog_green = 0x4C943D # Used for FROGTIPS
red = 0xe74c3c # Used for on_error
dark_red = 0x992d22 # Used for on_command_error


# REMEMBER TO UNCOMMENT THE GSS LINE, ROXIE


+ 4
- 4
Roxbot/logging.py View File

@@ -1,11 +1,11 @@
import discord
from Roxbot import guild_settings, embedcolour
from Roxbot import guild_settings, EmbedColours


async def log(guild, channel, command_name, **kwargs):
logging = guild_settings.get(guild).logging
if logging["enabled"]:
embed = discord.Embed(title="{} command logging".format(command_name), colour=embedcolour)
embed = discord.Embed(title="{} command logging".format(command_name), colour=EmbedColours.pink)
for key, value in kwargs.items():
embed.add_field(name=key, value=value)
return await channel.send(embed=embed)
@@ -19,7 +19,7 @@ class Logging:
logging = guild_settings.get(member.guild).logging
if logging["enabled"]:
channel = self.bot.get_channel(logging["channel"])
embed = discord.Embed(title="{} joined the server".format(member), colour=embedcolour)
embed = discord.Embed(title="{} joined the server".format(member), colour=EmbedColours.pink)
embed.add_field(name="ID", value=member.id)
embed.add_field(name="Mention", value=member.mention)
embed.add_field(name="Date Account Created", value="{:%a %Y/%m/%d %H:%M:%S} UTC".format(member.created_at))
@@ -32,7 +32,7 @@ class Logging:
logging = guild_settings.get(member.guild).logging
if logging["enabled"]:
channel = self.bot.get_channel(logging["channel"])
embed = discord.Embed(description="{} left the server".format(member), colour=embedcolour)
embed = discord.Embed(description="{} left the server".format(member), colour=EmbedColours.pink)
return await channel.send(embed=embed)



+ 2
- 2
Roxbot/settings/settings.py View File

@@ -4,7 +4,7 @@ import aiohttp
import asyncio
import datetime

from Roxbot import checks, load_config, guild_settings
from Roxbot import checks, load_config, guild_settings, EmbedColours

import discord
from discord.ext.commands import bot, group, is_owner, bot_has_permissions
@@ -179,7 +179,7 @@ class Settings:
async def printsettings(self, ctx, option=None):
"OWNER OR ADMIN ONLY: Prints the servers settings file."
config = guild_settings.get(ctx.guild)
em = discord.Embed(colour=0xDEADBF)
em = discord.Embed(colour=EmbedColours.pink)
em.set_author(name="{} settings for {}.".format(self.bot.user.name, ctx.message.guild.name), icon_url=self.bot.user.avatar_url)
if option in config.settings:
settingcontent = ""

+ 1
- 1
main.py View File

@@ -81,7 +81,7 @@ async def about(ctx):
Outputs info about RoxBot, showing uptime, how to report issues, what settings where set in prefs.ini and credits.
"""
owner = bot.get_user(Roxbot.owner)
em = discord.Embed(title="About Roxbot", colour=Roxbot.embedcolour, description=Roxbot.__description__)
em = discord.Embed(title="About Roxbot", colour=Roxbot.EmbedColours.pink, description=Roxbot.__description__)
em.set_thumbnail(url=bot.user.avatar_url)
em.add_field(name="Command Prefix", value=Roxbot.command_prefix)
em.add_field(name="Owner", value=str(owner))

Loading…
Cancel
Save