1
0
Fork 0
mirror of synced 2024-05-29 08:49:38 +12:00

Use the full utils package instead of importing each individually

This commit is contained in:
Phxntxm 2017-02-12 17:45:19 -06:00
parent f9ce8ef85e
commit 04c07fc08c
2 changed files with 29 additions and 30 deletions

View file

@ -1,9 +1,10 @@
from .utils import *
from .voice_utilities import *
from .voice_utils import *
import discord
from discord.ext import commands
from . import utils
import math
import time
import asyncio
@ -321,7 +322,7 @@ class Music:
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def progress(self, ctx):
"""Provides the progress of the current song"""
@ -345,7 +346,7 @@ class Music:
await self.bot.say(fmt)
@commands.command(no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def join(self, *, channel: discord.Channel):
"""Joins a voice channel."""
try:
@ -361,7 +362,7 @@ class Music:
await self.bot.say('Ready to play audio in ' + channel.name)
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def summon(self, ctx):
"""Summons the bot to join your voice channel."""
# This method will be invoked by other commands, so we should return True or False instead of just returning
@ -388,7 +389,7 @@ class Music:
return success
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def play(self, ctx, *, song: str):
"""Plays a song.
If there is a song currently in the queue, then it is
@ -406,7 +407,7 @@ class Music:
state = self.get_voice_state(ctx.message.server)
# First check if we are connected to a voice channel at all, if not summon to the channel the author is in
# Since summon checks if the author is in a channel, we don't need to handle that here, just return if it failed
# Since summon utils if the author is in a channel, we don't need to handle that here, just return if it failed
if state.voice is None:
success = await ctx.invoke(self.summon)
if not success:
@ -479,7 +480,7 @@ class Music:
await self.bot.say('Enqueued ' + str(_entry))
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(kick_members=True)
@utils.custom_perms(kick_members=True)
async def volume(self, ctx, value: int = None):
"""Sets the volume of the currently playing song."""
@ -498,7 +499,7 @@ class Music:
await self.bot.say('Set the volume to {:.0%}'.format(player.volume))
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(kick_members=True)
@utils.custom_perms(kick_members=True)
async def pause(self, ctx):
"""Pauses the currently played song."""
state = self.get_voice_state(ctx.message.server)
@ -506,7 +507,7 @@ class Music:
state.player.pause()
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(kick_members=True)
@utils.custom_perms(kick_members=True)
async def resume(self, ctx):
"""Resumes the currently played song."""
state = self.get_voice_state(ctx.message.server)
@ -514,7 +515,7 @@ class Music:
state.player.resume()
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(kick_members=True)
@utils.custom_perms(kick_members=True)
async def stop(self, ctx):
"""Stops playing audio and leaves the voice channel.
This also clears the queue.
@ -538,7 +539,7 @@ class Music:
pass
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def eta(self, ctx):
"""Provides an ETA on when your next song will play"""
# Note: There is no way to tell how long a song has been playing, or how long there is left on a song
@ -578,7 +579,7 @@ class Music:
await self.bot.say("ETA till your next play is: {0[0]}m {0[1]}s".format(divmod(round(count, 0), 60)))
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def queue(self, ctx):
"""Provides a printout of the songs that are in the queue"""
state = self.get_voice_state(ctx.message.server)
@ -594,14 +595,14 @@ class Music:
self.bot.loop.create_task(self.queue_embed_task(state, ctx.message.channel, ctx.message.author))
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def queuelength(self, ctx):
"""Prints the length of the queue"""
await self.bot.say("There are a total of {} songs in the queue"
.format(len(self.get_voice_state(ctx.message.server).songs.entries)))
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def skip(self, ctx):
"""Vote to skip a song. The song requester can automatically skip.
approximately 1/3 of the members in the voice channel
@ -633,7 +634,7 @@ class Music:
await self.bot.say('You have already voted to skip this song.')
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(kick_members=True)
@utils.custom_perms(kick_members=True)
async def modskip(self, ctx):
"""Forces a song skip, can only be used by a moderator"""
state = self.get_voice_state(ctx.message.server)
@ -645,7 +646,7 @@ class Music:
await self.bot.say('Song has just been skipped.')
@commands.command(pass_context=True, no_pm=True)
@checks.custom_perms(send_messages=True)
@utils.custom_perms(send_messages=True)
async def playing(self, ctx):
"""Shows info about the currently played song."""

View file

@ -1,8 +1,6 @@
from discord.ext import commands
from .utils import config
from .utils import checks
from .utils import utilities
from . import utils
import re
import glob
@ -23,7 +21,7 @@ class Owner:
self.bot = bot
@commands.command()
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def motd_push(self, *, message):
"""Used to push a new message to the message of the day"""
date = pendulum.utcnow().to_date_string()
@ -31,12 +29,12 @@ class Owner:
entry = {'motd': message, 'date': date}
# Try to add this, if there's an entry for that date, lets update it to make sure only one motd is sent a day
# I should be managing this myself, more than one should not be sent in a day
if await config.add_content('motd', entry, r_filter):
await config.update_content('motd', entry, r_filter)
if await utils.add_content('motd', entry, r_filter):
await utils.update_content('motd', entry, r_filter)
await self.bot.say("New motd update for {}!".format(date))
@commands.command(pass_context=True)
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def debug(self, ctx):
"""Executes code"""
# Eval and exec have different useful purposes, so use both
@ -65,7 +63,7 @@ class Owner:
await self.bot.say(fmt.format(type(error).__name__, error))
@commands.command(pass_context=True)
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def shutdown(self, ctx):
"""Shuts the bot down"""
fmt = 'Shutting down, I will miss you {0.author.name}'
@ -74,21 +72,21 @@ class Owner:
await self.bot.close()
@commands.command()
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def name(self, newNick: str):
"""Changes the bot's name"""
await self.bot.edit_profile(username=newNick)
await self.bot.say('Changed username to ' + newNick)
@commands.command()
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def status(self, *, status: str):
"""Changes the bot's 'playing' status"""
await self.bot.change_status(discord.Game(name=status, type=0))
await self.bot.say("Just changed my status to '{0}'!".format(status))
@commands.command()
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def load(self, *, module: str):
"""Loads a module"""
@ -106,7 +104,7 @@ class Owner:
await self.bot.say(fmt.format(type(error).__name__, error))
@commands.command()
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def unload(self, *, module: str):
"""Unloads a module"""
@ -119,7 +117,7 @@ class Owner:
await self.bot.say("I have just unloaded the {} module".format(module))
@commands.command()
@commands.check(checks.is_owner)
@commands.check(utils.is_owner)
async def reload(self, *, module: str):
"""Reloads a module"""