From c9bd086eac166e974f41a047dad32e8756207c4d Mon Sep 17 00:00:00 2001 From: Jaimyn Mayer Date: Fri, 4 May 2018 00:26:02 +1000 Subject: [PATCH] Added listener (pm user on guild join) example Added an example of how to use listeners to react to events. The example demonstrates how to dm someone a welcome message after they join a guild. --- examples/basic_plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/basic_plugin.py b/examples/basic_plugin.py index d056dba..cf39f16 100644 --- a/examples/basic_plugin.py +++ b/examples/basic_plugin.py @@ -73,3 +73,9 @@ class BasicPlugin(Plugin): if args.help: return event.msg.reply(event.parser.format_help()) event.msg.reply(args.asdf) + + # You can use a listener to react to events, like someone joining your guild + @Plugin.listen('GuildMemberAdd') + def send_welcome_dm(self, event): + # Send the user a direct message with a welcome greeting after they join. + event.member.user.open_dm().send_message('Hi there! Welcome to our friendly community.')