1
0
Fork 0
mirror of synced 2024-06-18 18:44:33 +12:00

Added the ability to change user notifications

This commit is contained in:
Phxntxm 2016-08-01 11:10:20 -05:00
parent 95b28f87c1
commit 8e30e32f8b
2 changed files with 18 additions and 3 deletions

8
bot.py
View file

@ -49,7 +49,9 @@ async def on_member_join(member):
server_notifications = notifications.get(member.server.id)
if not server_notifications:
return
await bot.send_message(member.server, "Welcome to the '{0.server.name}' server {0.mention}!".format(member))
channel = discord.utils.get(member.server.channels,id=server_notifications)
await bot.send_message(channel, "Welcome to the '{0.server.name}' server {0.mention}!".format(member))
@bot.event
@ -58,7 +60,9 @@ async def on_member_remove(member):
server_notifications = notifications.get(member.server.id)
if not server_notifications:
return
await bot.send_message(member.server,
channel = discord.utils.get(member.server.channels,id=server_notifications)
await bot.send_message(channel,
"{0} has left the server, I hope it wasn't because of something I said :c".format(member))

View file

@ -12,7 +12,18 @@ class Mod:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True, no_pm=True)
async def usernotify(self, ctx, on_off:str):
"""This command can be used to set whether or not you want user notificaitons to show
This will save what channel you run this command in, that will be the channel used to send the notification to
Provide on, yes, or true to set it on; otherwise it will be turned off"""
on_off = ctx.message.channel.id if re.search("(on|yes|true)",on_off.lower()) else None
notifications = config.getContent('user_notifications') or {}
notifications[ctx.message.server.id] = on_off
config.saveContent('user_notifications',notifications)
fmt = "notify, in this channel" if on_off else "not notify"
await self.bot.say("This server will now {} if someone has joined or left".format(fmt))
@commands.group(pass_context=True, no_pm=True)
async def nsfw(self, ctx):
"""Handles adding or removing a channel as a nsfw channel"""