Updates to comply with PEP 8
This commit is contained in:
parent
560d15eb62
commit
8e050c016e
9 changed files with 100 additions and 109 deletions
1
bot.py
1
bot.py
|
@ -27,6 +27,7 @@ log.setLevel(logging.INFO)
|
||||||
handler = logging.FileHandler(filename='bonfire.log', encoding='utf-8', mode='a')
|
handler = logging.FileHandler(filename='bonfire.log', encoding='utf-8', mode='a')
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
# Bot event overrides
|
# Bot event overrides
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
|
|
@ -102,7 +102,6 @@ class Core:
|
||||||
fortune = subprocess.check_output(fortuneCommand.split()).decode("utf-8")
|
fortune = subprocess.check_output(fortuneCommand.split()).decode("utf-8")
|
||||||
await self.bot.say(fortune)
|
await self.bot.say(fortune)
|
||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@checks.customPermsOrRole(send_messages=True)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
async def roll(self, ctx, notation: str="d6"):
|
async def roll(self, ctx, notation: str="d6"):
|
||||||
|
|
37
cogs/mod.py
37
cogs/mod.py
|
@ -77,7 +77,7 @@ class Mod:
|
||||||
await self.bot.say("That command has no custom permissions setup on it!")
|
await self.bot.say("That command has no custom permissions setup on it!")
|
||||||
else:
|
else:
|
||||||
permissions = discord.Permissions(perms_value)
|
permissions = discord.Permissions(perms_value)
|
||||||
needed_perm = [perm[0] for perm in permissions._perm_iterator() if perm[1]][0]
|
needed_perm = [perm[0] for perm in permissions if perm[1]][0]
|
||||||
await self.bot.say("You need to have the permission `{}` "
|
await self.bot.say("You need to have the permission `{}` "
|
||||||
"to use the command `{}` in this server".format(needed_perm, command))
|
"to use the command `{}` in this server".format(needed_perm, command))
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ class Mod:
|
||||||
command = " ".join(msg[0:len(msg) - 1])
|
command = " ".join(msg[0:len(msg) - 1])
|
||||||
permissions = msg[len(msg) - 1]
|
permissions = msg[len(msg) - 1]
|
||||||
|
|
||||||
#If a user can run the command, they have to have send_messages permissions; so use this as the base
|
# If a user can run the command, they have to have send_messages permissions; so use this as the base
|
||||||
if permissions.lower() == "none":
|
if permissions.lower() == "none":
|
||||||
permissions = "send_messages"
|
permissions = "send_messages"
|
||||||
|
|
||||||
#Convert the string to an int value of the permissions obj, based on the required permission
|
# Convert the string to an int value of the permissions obj, based on the required permission
|
||||||
perm_obj = discord.Permissions.none()
|
perm_obj = discord.Permissions.none()
|
||||||
setattr(perm_obj,permissions,True)
|
setattr(perm_obj, permissions, True)
|
||||||
perm_value = perm_obj.value
|
perm_value = perm_obj.value
|
||||||
|
|
||||||
cmd = None
|
cmd = None
|
||||||
|
@ -110,7 +110,8 @@ class Mod:
|
||||||
break
|
break
|
||||||
|
|
||||||
if cmd is None:
|
if cmd is None:
|
||||||
await self.bot.say("That command does not exist! You can't have custom permissions on a non-existant command....")
|
await self.bot.say(
|
||||||
|
"That command does not exist! You can't have custom permissions on a non-existant command....")
|
||||||
return
|
return
|
||||||
|
|
||||||
for check in cmd.checks:
|
for check in cmd.checks:
|
||||||
|
@ -159,7 +160,7 @@ class Mod:
|
||||||
if server_rules is None or len(server_rules) == 0:
|
if server_rules is None or len(server_rules) == 0:
|
||||||
await self.bot.say("This server currently has no rules on it! I see you like to live dangerously...")
|
await self.bot.say("This server currently has no rules on it! I see you like to live dangerously...")
|
||||||
return
|
return
|
||||||
fmt = "\n".join("{}) {}".format(num+1,rule) for num,rule in enumerate(server_rules))
|
fmt = "\n".join("{}) {}".format(num + 1, rule) for num, rule in enumerate(server_rules))
|
||||||
await self.bot.say('```{}```'.format(fmt))
|
await self.bot.say('```{}```'.format(fmt))
|
||||||
|
|
||||||
@rules.command(name='add', aliases=['create'], pass_context=True, no_pm=True)
|
@rules.command(name='add', aliases=['create'], pass_context=True, no_pm=True)
|
||||||
|
@ -170,7 +171,7 @@ class Mod:
|
||||||
server_rules = rules.get(ctx.message.server.id) or []
|
server_rules = rules.get(ctx.message.server.id) or []
|
||||||
server_rules.append(rule)
|
server_rules.append(rule)
|
||||||
rules[ctx.message.server.id] = server_rules
|
rules[ctx.message.server.id] = server_rules
|
||||||
config.saveContent('rules',rules)
|
config.saveContent('rules', rules)
|
||||||
await self.bot.say("I have just saved your new rule, use the rules command to view this server's current rules")
|
await self.bot.say("I have just saved your new rule, use the rules command to view this server's current rules")
|
||||||
|
|
||||||
@rules.command(name='remove', aliases=['delete'], pass_context=True, no_pm=True)
|
@rules.command(name='remove', aliases=['delete'], pass_context=True, no_pm=True)
|
||||||
|
@ -182,28 +183,32 @@ class Mod:
|
||||||
rules = config.getContent('rules') or {}
|
rules = config.getContent('rules') or {}
|
||||||
server_rules = rules.get(ctx.message.server.id)
|
server_rules = rules.get(ctx.message.server.id)
|
||||||
if server_rules is None or len(server_rules) == 0:
|
if server_rules is None or len(server_rules) == 0:
|
||||||
await self.bot.say("This server currently has no rules on it! Can't remove something that doesn't exist bro")
|
await self.bot.say(
|
||||||
|
"This server currently has no rules on it! Can't remove something that doesn't exist bro")
|
||||||
return
|
return
|
||||||
list_rules = "\n".join("{}) {}".format(num+1,rule) for num,rule in enumerate(server_rules))
|
list_rules = "\n".join("{}) {}".format(num + 1, rule) for num, rule in enumerate(server_rules))
|
||||||
|
|
||||||
if rule is None:
|
if rule is None:
|
||||||
await self.bot.say("Your rules are:\n```{}```Please provide the rule number you would like to remove (just the number)".format(list_rules))
|
await self.bot.say("Your rules are:\n```{}```Please provide the rule number"
|
||||||
|
"you would like to remove (just the number)".format(list_rules))
|
||||||
|
|
||||||
msg = await self.bot.wait_for_message(timeout=60.0, author=ctx.message.author, channel = ctx.message.channel, check = lambda m: m.content.isdigit())
|
msg = await self.bot.wait_for_message(timeout=60.0, author=ctx.message.author, channel=ctx.message.channel,
|
||||||
|
check=lambda m: m.content.isdigit())
|
||||||
if msg is None:
|
if msg is None:
|
||||||
await self.bot.say("You took too long...it's just a number, seriously? Try typing a bit quicker")
|
await self.bot.say("You took too long...it's just a number, seriously? Try typing a bit quicker")
|
||||||
return
|
return
|
||||||
del server_rules[int(msg.content)-1]
|
del server_rules[int(msg.content) - 1]
|
||||||
rules[ctx.message.server.id] = server_rules
|
rules[ctx.message.server.id] = server_rules
|
||||||
config.saveContent('rules',rules)
|
config.saveContent('rules', rules)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
del server_rules[rule-1]
|
del server_rules[rule - 1]
|
||||||
rules[ctx.message.server.id] = server_rules
|
rules[ctx.message.server.id] = server_rules
|
||||||
config.saveContent('rules',rules)
|
config.saveContent('rules', rules)
|
||||||
await self.bot.say("I have just removed that rule from your list of rules!")
|
await self.bot.say("I have just removed that rule from your list of rules!")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
await self.bot.say("That is not a valid rule number, try running the command again. Your current rules are:\n```{}```".format(list_rules))
|
await self.bot.say("That is not a valid rule number, try running the command again. "
|
||||||
|
"Your current rules are:\n```{}```".format(list_rules))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
@ -5,7 +5,6 @@ import discord
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import json
|
import json
|
||||||
import re
|
|
||||||
|
|
||||||
base_url = "https://owapi.net/api/v2/u/"
|
base_url = "https://owapi.net/api/v2/u/"
|
||||||
check_g_stats = ["eliminations", "deaths", 'kpd', 'wins', 'losses', 'time_played',
|
check_g_stats = ["eliminations", "deaths", 'kpd', 'wins', 'losses', 'time_played',
|
||||||
|
@ -29,7 +28,7 @@ class Overwatch:
|
||||||
|
|
||||||
@ow.command(name="stats", pass_context=True, no_pm=True)
|
@ow.command(name="stats", pass_context=True, no_pm=True)
|
||||||
@checks.customPermsOrRole(send_messages=True)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
async def ow_stats(self, ctx, user: discord.Member = None, hero: str = ""):
|
async def ow_stats(self, ctx, user: discord.Member=None, hero: str=""):
|
||||||
"""Prints out a basic overview of a member's stats
|
"""Prints out a basic overview of a member's stats
|
||||||
Provide a hero after the member to get stats for that specific hero"""
|
Provide a hero after the member to get stats for that specific hero"""
|
||||||
if user is None:
|
if user is None:
|
||||||
|
@ -42,7 +41,7 @@ class Overwatch:
|
||||||
await self.bot.say("Searching profile information....")
|
await self.bot.say("Searching profile information....")
|
||||||
|
|
||||||
if hero == "":
|
if hero == "":
|
||||||
with aiohttp.ClientSession(headers={"User-Agent":"Bonfire/1.0.0"}) as s:
|
with aiohttp.ClientSession(headers={"User-Agent": "Bonfire/1.0.0"}) as s:
|
||||||
async with s.get(base_url + "{}/stats/general".format(bt)) as r:
|
async with s.get(base_url + "{}/stats/general".format(bt)) as r:
|
||||||
result = await r.text()
|
result = await r.text()
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ class Overwatch:
|
||||||
"Overwatch stats for {}: ```py\n{}```".format(user.name, fmt.title().replace("_", " ")))
|
"Overwatch stats for {}: ```py\n{}```".format(user.name, fmt.title().replace("_", " ")))
|
||||||
else:
|
else:
|
||||||
url = base_url + "{}/heroes/{}".format(bt, hero.lower().replace('-', ''))
|
url = base_url + "{}/heroes/{}".format(bt, hero.lower().replace('-', ''))
|
||||||
with aiohttp.ClientSession(headers={"User-Agent":"Bonfire/1.0.0"}) as s:
|
with aiohttp.ClientSession(headers={"User-Agent": "Bonfire/1.0.0"}) as s:
|
||||||
async with s.get(url) as r:
|
async with s.get(url) as r:
|
||||||
if r.status == 500:
|
if r.status == 500:
|
||||||
fmt = "{} has not used the hero {} before!".format(user.name, hero.title())
|
fmt = "{} has not used the hero {} before!".format(user.name, hero.title())
|
||||||
|
@ -81,7 +80,7 @@ class Overwatch:
|
||||||
await self.bot.say("Looking up your profile information....")
|
await self.bot.say("Looking up your profile information....")
|
||||||
url = base_url + "{}/stats/general".format(bt)
|
url = base_url + "{}/stats/general".format(bt)
|
||||||
|
|
||||||
with aiohttp.ClientSession(headers={"User-Agent":"Bonfire/1.0.0"}) as s:
|
with aiohttp.ClientSession(headers={"User-Agent": "Bonfire/1.0.0"}) as s:
|
||||||
async with s.get(url) as r:
|
async with s.get(url) as r:
|
||||||
if not r.status == 200:
|
if not r.status == 200:
|
||||||
await self.bot.say("Profile does not exist! Battletags are picky, "
|
await self.bot.say("Profile does not exist! Battletags are picky, "
|
||||||
|
|
|
@ -60,7 +60,8 @@ class VoiceState:
|
||||||
self.current = await self.songs.get()
|
self.current = await self.songs.get()
|
||||||
await self.bot.send_message(self.current.channel, 'Now playing ' + str(self.current))
|
await self.bot.send_message(self.current.channel, 'Now playing ' + str(self.current))
|
||||||
|
|
||||||
self.current.player = await self.voice.create_ytdl_player(self.current.player.url, ytdl_options=self.opts, after=self.toggle_next)
|
self.current.player = await self.voice.create_ytdl_player(self.current.player.url, ytdl_options=self.opts,
|
||||||
|
after=self.toggle_next)
|
||||||
self.current.player.start()
|
self.current.player.start()
|
||||||
await self.play_next_song.wait()
|
await self.play_next_song.wait()
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ class Music:
|
||||||
"""Voice related commands.
|
"""Voice related commands.
|
||||||
Works in multiple servers at once.
|
Works in multiple servers at once.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.voice_states = {}
|
self.voice_states = {}
|
||||||
|
|
|
@ -2,8 +2,6 @@ from discord.ext import commands
|
||||||
from .utils import config
|
from .utils import config
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
import discord
|
import discord
|
||||||
import re
|
|
||||||
import operator
|
|
||||||
|
|
||||||
|
|
||||||
class Stats:
|
class Stats:
|
||||||
|
@ -17,7 +15,6 @@ class Stats:
|
||||||
async def mostboops(self, ctx):
|
async def mostboops(self, ctx):
|
||||||
"""Shows the person you have 'booped' the most, as well as how many times"""
|
"""Shows the person you have 'booped' the most, as well as how many times"""
|
||||||
boops = config.getContent('boops')
|
boops = config.getContent('boops')
|
||||||
members = ctx.message.server.members
|
|
||||||
if not boops.get(ctx.message.author.id):
|
if not boops.get(ctx.message.author.id):
|
||||||
await self.bot.say("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
await self.bot.say("You have not booped anyone {} Why the heck not...?".format(ctx.message.author.mention))
|
||||||
return
|
return
|
||||||
|
@ -36,7 +33,6 @@ class Stats:
|
||||||
@checks.customPermsOrRole(send_messages=True)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
async def listboops(self, ctx):
|
async def listboops(self, ctx):
|
||||||
"""Lists all the users you have booped and the amount of times"""
|
"""Lists all the users you have booped and the amount of times"""
|
||||||
members = ctx.message.server.members
|
|
||||||
boops = config.getContent('boops') or {}
|
boops = config.getContent('boops') or {}
|
||||||
booped_members = boops.get(ctx.message.author.id)
|
booped_members = boops.get(ctx.message.author.id)
|
||||||
if booped_members is None:
|
if booped_members is None:
|
||||||
|
@ -44,9 +40,11 @@ class Stats:
|
||||||
return
|
return
|
||||||
|
|
||||||
server_member_ids = [member.id for member in ctx.message.server.members]
|
server_member_ids = [member.id for member in ctx.message.server.members]
|
||||||
booped_members = {m_id:amt for m_id,amt in booped_members.items() if m_id in server_member_ids}
|
booped_members = {m_id: amt for m_id, amt in booped_members.items() if m_id in server_member_ids}
|
||||||
|
|
||||||
output = "\n".join("{0.display_name}: {1} times".format(discord.utils.get(self.bot.get_all_members(),id=m_id),amt) for m_id,amt in booped_members)
|
output = "\n".join(
|
||||||
|
"{0.display_name}: {1} times".format(discord.utils.get(self.bot.get_all_members(), id=m_id), amt) for
|
||||||
|
m_id, amt in booped_members)
|
||||||
await self.bot.say("You have booped:```{}```".format(output))
|
await self.bot.say("You have booped:```{}```".format(output))
|
||||||
|
|
||||||
@commands.command(pass_context=True, no_pm=True)
|
@commands.command(pass_context=True, no_pm=True)
|
||||||
|
@ -56,19 +54,18 @@ class Stats:
|
||||||
battles = config.getContent('battle_records')
|
battles = config.getContent('battle_records')
|
||||||
|
|
||||||
server_member_ids = [member.id for member in ctx.message.server.members]
|
server_member_ids = [member.id for member in ctx.message.server.members]
|
||||||
server_members = {member_id:stats for member_id,stats in battles.items() if member_id in server_member_ids}
|
server_members = {member_id: stats for member_id, stats in battles.items() if member_id in server_member_ids}
|
||||||
sorted_members = sorted(server_members.items(), key = lambda x: x[1]['rating'],reverse=True)
|
sorted_members = sorted(server_members.items(), key=lambda k: k[1]['rating'], reverse=True)
|
||||||
|
|
||||||
fmt = ""
|
fmt = ""
|
||||||
count = 1
|
count = 1
|
||||||
for x in sorted_members:
|
for x in sorted_members:
|
||||||
member_id = x[0]
|
member_id = x[0]
|
||||||
stats = x[1]
|
stats = x[1]
|
||||||
member = discord.utils.get(ctx.message.server.members,id=member_id)
|
member = discord.utils.get(ctx.message.server.members, id=member_id)
|
||||||
fmt += "#{}) {} (Rating: {})\n".format(count,member.display_name,stats.get('rating'))
|
fmt += "#{}) {} (Rating: {})\n".format(count, member.display_name, stats.get('rating'))
|
||||||
count += 1
|
count += 1
|
||||||
await self.bot.say("You have booped:```{}```".format(fmt))
|
await self.bot.say("Battling leaderboard for this server:```{}```".format(fmt))
|
||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@checks.customPermsOrRole(send_messages=True)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
|
@ -77,22 +74,25 @@ class Stats:
|
||||||
member = member or ctx.message.author
|
member = member or ctx.message.author
|
||||||
|
|
||||||
all_members = config.getContent('battle_records')
|
all_members = config.getContent('battle_records')
|
||||||
if not member.id in all_members:
|
if member.id not in all_members:
|
||||||
await self.bot.say("That user has not battled yet!")
|
await self.bot.say("That user has not battled yet!")
|
||||||
return
|
return
|
||||||
|
|
||||||
server_member_ids = [member.id for member in ctx.message.server.members]
|
server_member_ids = [member.id for member in ctx.message.server.members]
|
||||||
server_members = {member_id:stats for member_id,stats in all_members.items() if member_id in server_member_ids}
|
server_members = {member_id: stats for member_id, stats in all_members.items() if
|
||||||
sorted_server_members = sorted(server_members.items(), key = lambda x: x[1]['rating'],reverse=True)
|
member_id in server_member_ids}
|
||||||
sorted_all_members = sorted(all_members.items(), key = lambda x: x[1]['rating'],reverse=True)
|
sorted_server_members = sorted(server_members.items(), key=lambda x: x[1]['rating'], reverse=True)
|
||||||
|
sorted_all_members = sorted(all_members.items(), key=lambda x: x[1]['rating'], reverse=True)
|
||||||
|
|
||||||
server_rank = [i for i,x in enumerate(sorted_server_members) if x[0] == member.id][0] + 1
|
server_rank = [i for i, x in enumerate(sorted_server_members) if x[0] == member.id][0] + 1
|
||||||
total_rank = [i for i,x in enumerate(sorted_all_members) if x[0] == member.id][0] + 1
|
total_rank = [i for i, x in enumerate(sorted_all_members) if x[0] == member.id][0] + 1
|
||||||
rating = server_members[member.id]['rating']
|
rating = server_members[member.id]['rating']
|
||||||
record = "{}-{}".format(server_members[member.id]['wins'],server_members[member.id]['losses'])
|
record = "{}-{}".format(server_members[member.id]['wins'], server_members[member.id]['losses'])
|
||||||
fmt = 'Stats for {}:\n\tRecord: {}\n\tServer Rank: {}/{}\n\tOverall Rank: {}/{}\n\tRating: {}'
|
fmt = 'Stats for {}:\n\tRecord: {}\n\tServer Rank: {}/{}\n\tOverall Rank: {}/{}\n\tRating: {}'
|
||||||
fmt = fmt.format(member.display_name,record,server_rank,len(server_members),total_rank,len(all_members),rating)
|
fmt = fmt.format(member.display_name, record, server_rank, len(server_members), total_rank, len(all_members),
|
||||||
|
rating)
|
||||||
await self.bot.say('```{}```'.format(fmt))
|
await self.bot.say('```{}```'.format(fmt))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Stats(bot))
|
bot.add_cog(Stats(bot))
|
||||||
|
|
10
cogs/tags.py
10
cogs/tags.py
|
@ -2,6 +2,7 @@ from discord.ext import commands
|
||||||
from .utils import config
|
from .utils import config
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
|
|
||||||
|
|
||||||
class Tags:
|
class Tags:
|
||||||
"""This class contains all the commands for custom tags"""
|
"""This class contains all the commands for custom tags"""
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ class Tags:
|
||||||
async def tags(self, ctx):
|
async def tags(self, ctx):
|
||||||
"""Prints all the custom tags that this server currently has"""
|
"""Prints all the custom tags that this server currently has"""
|
||||||
tags = config.getContent('tags')
|
tags = config.getContent('tags')
|
||||||
fmt = "\n".join("{}".format(tag['tag']) for tag in tags if tag['server_id']==ctx.message.server.id)
|
fmt = "\n".join("{}".format(tag['tag']) for tag in tags if tag['server_id'] == ctx.message.server.id)
|
||||||
await self.bot.say('```{}```'.format(fmt))
|
await self.bot.say('```{}```'.format(fmt))
|
||||||
|
|
||||||
@commands.group(pass_context=True, invoke_without_command=True, no_pm=True)
|
@commands.group(pass_context=True, invoke_without_command=True, no_pm=True)
|
||||||
|
@ -43,13 +44,15 @@ class Tags:
|
||||||
if t['tag'] == tag and t['server_id'] == ctx.message.server.id:
|
if t['tag'] == tag and t['server_id'] == ctx.message.server.id:
|
||||||
t['result'] = tag_result
|
t['result'] = tag_result
|
||||||
if config.saveContent('tags', tags):
|
if config.saveContent('tags', tags):
|
||||||
await self.bot.say("I have just updated the tag `{0}`! You can call this tag by entering !tag {0}".format(tag))
|
await self.bot.say(
|
||||||
|
"I have just updated the tag `{0}`! You can call this tag by entering !tag {0}".format(tag))
|
||||||
else:
|
else:
|
||||||
await self.bot.say("I was unable to save this data")
|
await self.bot.say("I was unable to save this data")
|
||||||
return
|
return
|
||||||
tags.append({'server_id': ctx.message.server.id, 'tag': tag, 'result': tag_result})
|
tags.append({'server_id': ctx.message.server.id, 'tag': tag, 'result': tag_result})
|
||||||
if config.saveContent('tags', tags):
|
if config.saveContent('tags', tags):
|
||||||
await self.bot.say("I have just added the tag `{0}`! You can call this tag by entering !tag {0}".format(tag))
|
await self.bot.say(
|
||||||
|
"I have just added the tag `{0}`! You can call this tag by entering !tag {0}".format(tag))
|
||||||
else:
|
else:
|
||||||
await self.bot.say("I was unable to save this data")
|
await self.bot.say("I was unable to save this data")
|
||||||
|
|
||||||
|
@ -72,5 +75,6 @@ class Tags:
|
||||||
else:
|
else:
|
||||||
await self.bot.say("I was unable to save this data")
|
await self.bot.say("I was unable to save this data")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Tags(bot))
|
bot.add_cog(Tags(bot))
|
||||||
|
|
|
@ -41,14 +41,14 @@ class Twitch:
|
||||||
twitch[m_id]['live'] = 1
|
twitch[m_id]['live'] = 1
|
||||||
fmt = "{} has just gone live! View their stream at {}".format(member.name, url)
|
fmt = "{} has just gone live! View their stream at {}".format(member.name, url)
|
||||||
await self.bot.send_message(server, fmt)
|
await self.bot.send_message(server, fmt)
|
||||||
config.saveContent('twitch',twitch)
|
config.saveContent('twitch', twitch)
|
||||||
elif live and not online:
|
elif live and not online:
|
||||||
server = discord.utils.find(lambda s: s.id == r['server_id'], self.bot.servers)
|
server = discord.utils.find(lambda s: s.id == r['server_id'], self.bot.servers)
|
||||||
member = discord.utils.find(lambda m: m.id == m_id, server.members)
|
member = discord.utils.find(lambda m: m.id == m_id, server.members)
|
||||||
twitch[m_id]['live'] = 0
|
twitch[m_id]['live'] = 0
|
||||||
fmt = "{} has just gone offline! Catch them next time they stream at {}".format(member.name, url)
|
fmt = "{} has just gone offline! Catch them next time they stream at {}".format(member.name, url)
|
||||||
await self.bot.send_message(server,fmt)
|
await self.bot.send_message(server, fmt)
|
||||||
config.saveContent('twitch',twitch)
|
config.saveContent('twitch', twitch)
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
@commands.group(no_pm=True, invoke_without_command=True, pass_context=True)
|
@commands.group(no_pm=True, invoke_without_command=True, pass_context=True)
|
||||||
|
|
|
@ -7,24 +7,6 @@ def isOwner(ctx):
|
||||||
return ctx.message.author.id == config.ownerID
|
return ctx.message.author.id == config.ownerID
|
||||||
|
|
||||||
|
|
||||||
def customPermsOrRole(perm):
|
|
||||||
def predicate(ctx):
|
|
||||||
if ctx.message.channel.is_private:
|
|
||||||
return False
|
|
||||||
custom_permissions = config.getContent('custom_permissions')
|
|
||||||
_perm = None
|
|
||||||
try:
|
|
||||||
_perm = custom_permissions[ctx.message.server.id][str(ctx.command)]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if _perm is None:
|
|
||||||
return getattr(ctx.message.author.permissions_in(ctx.message.channel), perm)
|
|
||||||
else:
|
|
||||||
return getattr(ctx.message.author.permissions_in(ctx.message.channel), _perm)
|
|
||||||
|
|
||||||
return commands.check(predicate)
|
|
||||||
|
|
||||||
def customPermsOrRole(**perms):
|
def customPermsOrRole(**perms):
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
if ctx.message.channel.is_private:
|
if ctx.message.channel.is_private:
|
||||||
|
@ -32,8 +14,8 @@ def customPermsOrRole(**perms):
|
||||||
|
|
||||||
member_perms = ctx.message.author.permissions_in(ctx.message.channel)
|
member_perms = ctx.message.author.permissions_in(ctx.message.channel)
|
||||||
default_perms = discord.Permissions.none()
|
default_perms = discord.Permissions.none()
|
||||||
for perm,setting in perms.items():
|
for perm, setting in perms.items():
|
||||||
setattr(default_perms,perm,setting)
|
setattr(default_perms, perm, setting)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
required_perm = config.getContent('custom_permissions')[ctx.message.server.id][ctx.command.qualified_name]
|
required_perm = config.getContent('custom_permissions')[ctx.message.server.id][ctx.command.qualified_name]
|
||||||
|
@ -41,7 +23,6 @@ def customPermsOrRole(**perms):
|
||||||
required_perm = default_perms
|
required_perm = default_perms
|
||||||
return member_perms >= required_perm
|
return member_perms >= required_perm
|
||||||
|
|
||||||
|
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue