Modified cogs to print an error if Bonfire could not save any data
This commit is contained in:
parent
706dedb980
commit
dd0d54954d
17
cogs/core.py
17
cogs/core.py
|
@ -169,11 +169,16 @@ class Core:
|
|||
for t in tags:
|
||||
if t['tag'] == tag and t['server_id'] == ctx.message.server.id:
|
||||
t['result'] = tag_result
|
||||
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))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
return
|
||||
tags.append({'server_id': ctx.message.server.id, 'tag': tag, 'result': tag_result})
|
||||
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))
|
||||
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))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@tag.command(name='delete', aliases=['remove', 'stop'], pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("kick_members")
|
||||
|
@ -190,8 +195,10 @@ class Core:
|
|||
for t in tags:
|
||||
if t['tag'] == tag and t['server_id'] == ctx.message.server.id:
|
||||
tags.remove(t)
|
||||
config.saveContent('tags', tags)
|
||||
await self.bot.say('I have just removed the tag `{}`'.format(tag))
|
||||
if config.saveContent('tags', tags):
|
||||
await self.bot.say('I have just removed the tag `{}`'.format(tag))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
|
@ -34,7 +34,9 @@ def updateBattleRecords(winner, loser):
|
|||
battles[loser.id] = "-".join(result)
|
||||
else:
|
||||
battles = {winner.id: "1-0", loser.id: "0-1"}
|
||||
config.saveContent('battle_records', battles)
|
||||
if config.saveContent('battle_records', battles):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Interaction:
|
||||
|
@ -82,11 +84,13 @@ class Interaction:
|
|||
fmt = config.battleWins[random.randint(0, len(config.battleWins) - 1)]
|
||||
if num <= 50:
|
||||
await self.bot.say(fmt.format(battleP1.mention, battleP2.mention))
|
||||
updateBattleRecords(battleP1, battleP2)
|
||||
if not updateBattleRecords(battleP1, battleP2):
|
||||
await self.bot.say("I was unable to save this data")
|
||||
battlingOff()
|
||||
elif num > 50:
|
||||
await self.bot.say(fmt.format(battleP2.mention, battleP1.mention))
|
||||
updateBattleRecords(battleP2, battleP1)
|
||||
if not updateBattleRecords(battleP2, battleP1):
|
||||
await self.bot.say("I was unable to save this data")
|
||||
battlingOff()
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
|
@ -96,7 +100,8 @@ class Interaction:
|
|||
if not battling or battleP2 != ctx.message.author:
|
||||
return
|
||||
await self.bot.say("{0} has chickened out! {1} wins by default!".format(battleP2.mention, battleP1.mention))
|
||||
updateBattleRecords(battleP1, battleP2)
|
||||
if not updateBattleRecords(battleP1, battleP2):
|
||||
await self.bot.say("I was unable to save this data")
|
||||
battlingOff()
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
|
@ -132,9 +137,11 @@ class Interaction:
|
|||
booper_boops[boopee.id] = amount
|
||||
boops[ctx.message.author.id] = booper_boops
|
||||
|
||||
config.saveContent('boops', boops)
|
||||
fmt = "{0.mention} has just booped you {1.mention}! That's {2} times now!"
|
||||
await self.bot.say(fmt.format(booper, boopee, amount))
|
||||
if config.saveContent('boops', boops):
|
||||
fmt = "{0.mention} has just booped you {1.mention}! That's {2} times now!"
|
||||
await self.bot.say(fmt.format(booper, boopee, amount))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
26
cogs/mod.py
26
cogs/mod.py
|
@ -28,8 +28,10 @@ class Mod:
|
|||
await self.bot.say("This channel is already registered as 'nsfw'!")
|
||||
else:
|
||||
nsfw_channels.append(ctx.message.channel.id)
|
||||
config.saveContent('nsfw_channels', nsfw_channels)
|
||||
await self.bot.say("This channel has just been registered as 'nsfw'! Have fun you naughties ;)")
|
||||
if config.saveContent('nsfw_channels', nsfw_channels):
|
||||
await self.bot.say("This channel has just been registered as 'nsfw'! Have fun you naughties ;)")
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@nsfw.command(name="remove", aliases=["delete"], pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("kick_members")
|
||||
|
@ -40,8 +42,10 @@ class Mod:
|
|||
await self.bot.say("This channel is not registered as a ''nsfw' channel!")
|
||||
else:
|
||||
nsfw_channels.remove(ctx.message.channel.id)
|
||||
config.saveContent('nsfw_channels', nsfw_channels)
|
||||
await self.bot.say("This channel has just been unregistered as a nsfw channel")
|
||||
if config.saveContent('nsfw_channels', nsfw_channels):
|
||||
await self.bot.say("This channel has just been unregistered as a nsfw channel")
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("manage_server")
|
||||
|
@ -122,9 +126,11 @@ class Mod:
|
|||
else:
|
||||
server_perms[command] = permissions
|
||||
custom_perms[ctx.message.server.id] = server_perms
|
||||
config.saveContent('custom_permissions', custom_perms)
|
||||
await self.bot.say("I have just added your custom permissions; "
|
||||
"you now need to have `{}` permissions to use the command `{}`".format(permissions, command))
|
||||
if config.saveContent('custom_permissions', custom_perms):
|
||||
await self.bot.say("I have just added your custom permissions; "
|
||||
"you now need to have `{}` permissions to use the command `{}`".format(permissions, command))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@perms.command(name="remove", aliases=["delete"], pass_context=True, no_pm=True)
|
||||
@commands.has_permissions(manage_server=True)
|
||||
|
@ -144,8 +150,10 @@ class Mod:
|
|||
await self.bot.say("You do not have custom permissions setup on this command yet!")
|
||||
return
|
||||
del custom_perms[ctx.message.server.id][cmd]
|
||||
config.saveContent('custom_permissions', custom_perms)
|
||||
await self.bot.say("I have just removed the custom permissions for {}!".format(cmd))
|
||||
if config.saveContent('custom_permissions', custom_perms):
|
||||
await self.bot.say("I have just removed the custom permissions for {}!".format(cmd))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
|
@ -80,9 +80,10 @@ class Overwatch:
|
|||
return
|
||||
ow = config.getContent('overwatch')
|
||||
ow[ctx.message.author.id] = bt
|
||||
config.saveContent('overwatch', ow)
|
||||
|
||||
await self.bot.say("I have just saved your battletag {}".format(ctx.message.author.mention))
|
||||
if config.saveContent('overwatch', ow):
|
||||
await self.bot.say("I have just saved your battletag {}".format(ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@ow.command(pass_context=True, name="delete", aliases=['remove'], no_pm=True)
|
||||
@checks.customPermsOrRole("none")
|
||||
|
@ -91,8 +92,10 @@ class Overwatch:
|
|||
result = config.getContent('overwatch')
|
||||
if result.get(ctx.message.author.id):
|
||||
del result[ctx.message.author.id]
|
||||
config.saveContent('overwatch', result)
|
||||
await self.bot.say("I no longer have your battletag saved {}".format(ctx.message.author.mention))
|
||||
if config.saveContent('overwatch', result):
|
||||
await self.bot.say("I no longer have your battletag saved {}".format(ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
else:
|
||||
await self.bot.say("I don't even have your battletag saved {}".format(ctx.message.author.mention))
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ class Owner:
|
|||
@commands.check(checks.isOwner)
|
||||
async def restart(self, ctx):
|
||||
"""Forces the bot to restart"""
|
||||
config.saveContent('restart_server', ctx.message.channel.id)
|
||||
await self.bot.say("Restarting; see you in the next life {0}!".format(ctx.message.author.mention))
|
||||
if config.saveContent('restart_server', ctx.message.channel.id):
|
||||
await self.bot.say("Restarting; see you in the next life {0}!".format(ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
python = sys.executable
|
||||
os.execl(python, python, *sys.argv)
|
||||
|
||||
|
|
|
@ -94,8 +94,10 @@ class Twitch:
|
|||
else:
|
||||
twitch[ctx.message.author.id] = {'twitch_url': url, 'server_id': ctx.message.server.id,
|
||||
'notifications_on': 1, 'live': 0}
|
||||
config.saveContent('twitch', twitch)
|
||||
await self.bot.say("I have just saved your twitch url {}".format(ctx.message.author.mention))
|
||||
if config.saveContent('twitch', twitch):
|
||||
await self.bot.say("I have just saved your twitch url {}".format(ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@twitch.command(name='remove', aliases=['delete'], pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("none")
|
||||
|
@ -104,8 +106,10 @@ class Twitch:
|
|||
twitch = config.getContent('twitch')
|
||||
if twitch.get(ctx.message.author.id) is not None:
|
||||
del twitch[ctx.message.author.id]
|
||||
config.saveContent('twitch', twitch)
|
||||
await self.bot.say("I am no longer saving your twitch URL {}".format(ctx.message.author.mention))
|
||||
if config.saveContent('twitch', twitch):
|
||||
await self.bot.say("I am no longer saving your twitch URL {}".format(ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
else:
|
||||
await self.bot.say(
|
||||
"I do not have your twitch URL added {}. You can save your twitch url with !twitch add".format(
|
||||
|
@ -132,9 +136,11 @@ class Twitch:
|
|||
ctx.message.author.mention))
|
||||
else:
|
||||
twitch[ctx.message.author.id]['notifications_on'] = 1
|
||||
config.saveContent('twitch', twitch)
|
||||
await self.bot.say("I will notify if you go live {}, you'll get a bajillion followers I promise c:".format(
|
||||
ctx.message.author.mention))
|
||||
if config.saveContent('twitch', twitch):
|
||||
await self.bot.say("I will notify if you go live {}, you'll get a bajillion followers I promise c:".format(
|
||||
ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
@notify.command(name='off', aliases=['stop,no'], pass_context=True, no_pm=True)
|
||||
@checks.customPermsOrRole("none")
|
||||
|
@ -150,11 +156,13 @@ class Twitch:
|
|||
ctx.message.author.mention))
|
||||
else:
|
||||
twitch[ctx.message.author.id]['notifications_on'] = 0
|
||||
config.saveContent('twitch', twitch)
|
||||
await self.bot.say(
|
||||
"I will not notify if you go live anymore {}, "
|
||||
"are you going to stream some lewd stuff you don't want people to see?~".format(
|
||||
ctx.message.author.mention))
|
||||
if config.saveContent('twitch', twitch):
|
||||
await self.bot.say(
|
||||
"I will not notify if you go live anymore {}, "
|
||||
"are you going to stream some lewd stuff you don't want people to see?~".format(
|
||||
ctx.message.author.mention))
|
||||
else:
|
||||
await self.bot.say("I was unable to save this data")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
Loading…
Reference in a new issue