1
0
Fork 0
mirror of synced 2024-05-19 20:12:30 +12:00

Ensure the channel given exists

This commit is contained in:
Phxntxm 2017-06-15 21:27:33 -05:00
parent dc08406739
commit a09452247e
2 changed files with 11 additions and 5 deletions

View file

@ -145,19 +145,23 @@ class Administration:
@commands.guild_only()
@utils.custom_perms(kick_members=True)
async def notifications(self, ctx, channel: discord.TextChannel):
"""This command is used to set a channel as the server's 'notifications' channel
Any notifications (like someone going live on Twitch, or Picarto) will go to that channel
"""This command is used to set a channel as the server's default 'notifications' channel
Any notifications (like someone going live on Twitch, or Picarto) will go to that channel by default
This can be overridden with specific alerts command, such as `!picarto alerts #channel`
This command is just the default; the one used if there is no other one set.
EXAMPLE: !alerts #alerts
RESULT: No more alerts spammed in #general!"""
entry = {
'server_id': str(ctx.message.guild.id),
'notifications_channel': str(channel.id)
'notifications': {
'default': str(channel.id)
}
}
self.bot.db.save('server_settings', entry)
await ctx.send("I have just changed this server's 'notifications' channel"
"\nAll notifications will now go to `{}`".format(channel))
await ctx.send("I have just changed this server's default 'notifications' channel"
"\nAll notifications will now default to `{}`".format(channel))
@commands.command()
@commands.guild_only()

View file

@ -78,6 +78,8 @@ class Picarto:
channel_id = self.bot.db.load('server_settings', key=s_id,
pluck='notifications_channel') or int(s_id)
channel = server.get_channel(channel_id)
if channel is None:
channel = server.default_channel
try:
await channel.send(
"{} has just gone offline! View their stream next time at <{}>".format(