{"action":"created","comment":{"url":"https://api.github.com/repos/b1naryth1ef/disco/pulls/comments/150790054","pull_request_review_id":76389835,"id":150790054,"diff_hunk":"@@ -0,0 +1,67 @@\n+# Listeners\r\n+Listeners are a way to execute custom actions when a certain discord event happens. For example, on message creation, when a member joins or leaves a guild, or when someone changes user or nickname.\r\n+\r\n+## Listeners in disco\r\n+Listeners are easy to use and implement in Disco. First of all, we'll create a [plugin](https://b1naryth1ef.github.io/disco/bot_tutorial/building_block_plugins.html) like so:\r\n+```py\r\n+class MyPlugin(Plugin):\r\n+```\r\n+Now, inside this plugin, we'll create our first listener. A listener is built up following this syntax:\r\n+```py\r\n+@Plugin.listen('EventName')\r\n+def on_event_name(self, event):\r\n+    # Do something with the event\r\n+```\r\n+Change the `'EventName'` in the `.listen()` method to the event name you want to listen to, and give the `on_event_name` method a more descriptive name.\r\n+\r\n+Now, on to adding the first listener to our plugin.\r\n+The listener will listen for a new message and will reply with the exact same message every time. \r\n+```py\r\n+@Plugin.listen('MesageCreate')\r\n+def on_message_create(self, event):\r\n+    event.reply(event.message.content)\r\n+```\r\n+Let's create a nother listener, this time one that listens for a member that's added to the guild, when this happens, it will send a welcome message in a welcome channel. For this example, we'll asume the ID for that channel's ID is stored in a constant named `WELCOME_CHANNEL`:\r\n+```py\r\n+@Plugin.listen('GuildMemberAdd')\r\n+def on_member_add(self, event):\r\n+    self.bot.client.api.channels_messages_create(\r\n+        WELCOME_CHANNEL,\r\n+        'Welcome to the server {}'.format(event.member.user.mention())\r\n+    )\r\n+```\r\n+\r\n+A list of all discord events supported by disco can be found [here](https://b1naryth1ef.github.io/disco/api/disco_gateway_events.html) including event attributes and functions you can use on the event property.# Listeners\r\n+Listeners are a way to execute custom actions when a certain discord event happens. For example, on message creation, when a member joins or leaves a guild, or when someone changes user or nickname.\r\n+\r\n+## Listeners in disco\r","path":"docs/bot_tutorial/building_block_listeners.md","position":37,"original_position":37,"commit_id":"1e97b700d782611f8df4653f59d689f92d450aec","original_commit_id":"1e97b700d782611f8df4653f59d689f92d450aec","user":{"login":"Alkali-Metal","id":20218935,"avatar_url":"https://avatars1.githubusercontent.com/u/20218935?v=4","gravatar_id":"","url":"https://api.github.com/users/Alkali-Metal","html_url":"https://github.com/Alkali-Metal","followers_url":"https://api.github.com/users/Alkali-Metal/followers","following_url":"https://api.github.com/users/Alkali-Metal/following{/other_user}","gists_url":"https://api.github.com/users/Alkali-Metal/gists{/gist_id}","starred_url":"https://api.github.com/users/Alkali-Metal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alkali-Metal/subscriptions","organizations_url":"https://api.github.com/users/Alkali-Metal/orgs","repos_url":"https://api.github.com/users/Alkali-Metal/repos","events_url":"https://api.github.com/users/Alkali-Metal/events{/privacy}","received_events_url":"https://api.github.com/users/Alkali-Metal/received_events","type":"User","site_admin":false},"body":"Starts repeating the same stuff from here until the end.","created_at":"2017-11-14T10:17:13Z","updated_at":"2017-11-14T10:18:36Z","html_url":"https://github.com/b1naryth1ef/disco/pull/56#discussion_r150790054","pull_request_url":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/b1naryth1ef/disco/pulls/comments/150790054"},"html":{"href":"https://github.com/b1naryth1ef/disco/pull/56#discussion_r150790054"},"pull_request":{"href":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56","id":139985478,"html_url":"https://github.com/b1naryth1ef/disco/pull/56","diff_url":"https://github.com/b1naryth1ef/disco/pull/56.diff","patch_url":"https://github.com/b1naryth1ef/disco/pull/56.patch","issue_url":"https://api.github.com/repos/b1naryth1ef/disco/issues/56","number":56,"state":"open","locked":false,"title":"[WIP] Added more documentation in the bot tutorial directory","user":{"login":"MrLotU","id":18392003,"avatar_url":"https://avatars3.githubusercontent.com/u/18392003?v=4","gravatar_id":"","url":"https://api.github.com/users/MrLotU","html_url":"https://github.com/MrLotU","followers_url":"https://api.github.com/users/MrLotU/followers","following_url":"https://api.github.com/users/MrLotU/following{/other_user}","gists_url":"https://api.github.com/users/MrLotU/gists{/gist_id}","starred_url":"https://api.github.com/users/MrLotU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrLotU/subscriptions","organizations_url":"https://api.github.com/users/MrLotU/orgs","repos_url":"https://api.github.com/users/MrLotU/repos","events_url":"https://api.github.com/users/MrLotU/events{/privacy}","received_events_url":"https://api.github.com/users/MrLotU/received_events","type":"User","site_admin":false},"body":"Right now only added documentation for the Message Embeds, but I'll add more in the upcoming few weeks","created_at":"2017-09-08T08:52:04Z","updated_at":"2017-11-14T10:18:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"413f024e91d84d9cb49056e8fdae46983b172cd9","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56/commits","review_comments_url":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56/comments","review_comment_url":"https://api.github.com/repos/b1naryth1ef/disco/pulls/comments{/number}","comments_url":"https://api.github.com/repos/b1naryth1ef/disco/issues/56/comments","statuses_url":"https://api.github.com/repos/b1naryth1ef/disco/statuses/1e97b700d782611f8df4653f59d689f92d450aec","head":{"label":"MrLotU:patch-1","ref":"patch-1","sha":"1e97b700d782611f8df4653f59d689f92d450aec","user":{"login":"MrLotU","id":18392003,"avatar_url":"https://avatars3.githubusercontent.com/u/18392003?v=4","gravatar_id":"","url":"https://api.github.com/users/MrLotU","html_url":"https://github.com/MrLotU","followers_url":"https://api.github.com/users/MrLotU/followers","following_url":"https://api.github.com/users/MrLotU/following{/other_user}","gists_url":"https://api.github.com/users/MrLotU/gists{/gist_id}","starred_url":"https://api.github.com/users/MrLotU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrLotU/subscriptions","organizations_url":"https://api.github.com/users/MrLotU/orgs","repos_url":"https://api.github.com/users/MrLotU/repos","events_url":"https://api.github.com/users/MrLotU/events{/privacy}","received_events_url":"https://api.github.com/users/MrLotU/received_events","type":"User","site_admin":false},"repo":{"id":102735072,"name":"disco","full_name":"MrLotU/disco","owner":{"login":"MrLotU","id":18392003,"avatar_url":"https://avatars3.githubusercontent.com/u/18392003?v=4","gravatar_id":"","url":"https://api.github.com/users/MrLotU","html_url":"https://github.com/MrLotU","followers_url":"https://api.github.com/users/MrLotU/followers","following_url":"https://api.github.com/users/MrLotU/following{/other_user}","gists_url":"https://api.github.com/users/MrLotU/gists{/gist_id}","starred_url":"https://api.github.com/users/MrLotU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrLotU/subscriptions","organizations_url":"https://api.github.com/users/MrLotU/orgs","repos_url":"https://api.github.com/users/MrLotU/repos","events_url":"https://api.github.com/users/MrLotU/events{/privacy}","received_events_url":"https://api.github.com/users/MrLotU/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MrLotU/disco","description":"Discord Python library for people that like to dance","fork":true,"url":"https://api.github.com/repos/MrLotU/disco","forks_url":"https://api.github.com/repos/MrLotU/disco/forks","keys_url":"https://api.github.com/repos/MrLotU/disco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MrLotU/disco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MrLotU/disco/teams","hooks_url":"https://api.github.com/repos/MrLotU/disco/hooks","issue_events_url":"https://api.github.com/repos/MrLotU/disco/issues/events{/number}","events_url":"https://api.github.com/repos/MrLotU/disco/events","assignees_url":"https://api.github.com/repos/MrLotU/disco/assignees{/user}","branches_url":"https://api.github.com/repos/MrLotU/disco/branches{/branch}","tags_url":"https://api.github.com/repos/MrLotU/disco/tags","blobs_url":"https://api.github.com/repos/MrLotU/disco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MrLotU/disco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MrLotU/disco/git/refs{/sha}","trees_url":"https://api.github.com/repos/MrLotU/disco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MrLotU/disco/statuses/{sha}","languages_url":"https://api.github.com/repos/MrLotU/disco/languages","stargazers_url":"https://api.github.com/repos/MrLotU/disco/stargazers","contributors_url":"https://api.github.com/repos/MrLotU/disco/contributors","subscribers_url":"https://api.github.com/repos/MrLotU/disco/subscribers","subscription_url":"https://api.github.com/repos/MrLotU/disco/subscription","commits_url":"https://api.github.com/repos/MrLotU/disco/commits{/sha}","git_commits_url":"https://api.github.com/repos/MrLotU/disco/git/commits{/sha}","comments_url":"https://api.github.com/repos/MrLotU/disco/comments{/number}","issue_comment_url":"https://api.github.com/repos/MrLotU/disco/issues/comments{/number}","contents_url":"https://api.github.com/repos/MrLotU/disco/contents/{+path}","compare_url":"https://api.github.com/repos/MrLotU/disco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MrLotU/disco/merges","archive_url":"https://api.github.com/repos/MrLotU/disco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MrLotU/disco/downloads","issues_url":"https://api.github.com/repos/MrLotU/disco/issues{/number}","pulls_url":"https://api.github.com/repos/MrLotU/disco/pulls{/number}","milestones_url":"https://api.github.com/repos/MrLotU/disco/milestones{/number}","notifications_url":"https://api.github.com/repos/MrLotU/disco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MrLotU/disco/labels{/name}","releases_url":"https://api.github.com/repos/MrLotU/disco/releases{/id}","deployments_url":"https://api.github.com/repos/MrLotU/disco/deployments","created_at":"2017-09-07T12:35:54Z","updated_at":"2017-09-07T12:35:56Z","pushed_at":"2017-11-14T09:31:57Z","git_url":"git://github.com/MrLotU/disco.git","ssh_url":"git@github.com:MrLotU/disco.git","clone_url":"https://github.com/MrLotU/disco.git","svn_url":"https://github.com/MrLotU/disco","homepage":"https://b1naryth1ef.github.io/disco/","size":1370,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"b1naryth1ef:master","ref":"master","sha":"c00befeb105f5ec777ac1b359097543b7ab8479b","user":{"login":"b1naryth1ef","id":599433,"avatar_url":"https://avatars2.githubusercontent.com/u/599433?v=4","gravatar_id":"","url":"https://api.github.com/users/b1naryth1ef","html_url":"https://github.com/b1naryth1ef","followers_url":"https://api.github.com/users/b1naryth1ef/followers","following_url":"https://api.github.com/users/b1naryth1ef/following{/other_user}","gists_url":"https://api.github.com/users/b1naryth1ef/gists{/gist_id}","starred_url":"https://api.github.com/users/b1naryth1ef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/b1naryth1ef/subscriptions","organizations_url":"https://api.github.com/users/b1naryth1ef/orgs","repos_url":"https://api.github.com/users/b1naryth1ef/repos","events_url":"https://api.github.com/users/b1naryth1ef/events{/privacy}","received_events_url":"https://api.github.com/users/b1naryth1ef/received_events","type":"User","site_admin":false},"repo":{"id":64710850,"name":"disco","full_name":"b1naryth1ef/disco","owner":{"login":"b1naryth1ef","id":599433,"avatar_url":"https://avatars2.githubusercontent.com/u/599433?v=4","gravatar_id":"","url":"https://api.github.com/users/b1naryth1ef","html_url":"https://github.com/b1naryth1ef","followers_url":"https://api.github.com/users/b1naryth1ef/followers","following_url":"https://api.github.com/users/b1naryth1ef/following{/other_user}","gists_url":"https://api.github.com/users/b1naryth1ef/gists{/gist_id}","starred_url":"https://api.github.com/users/b1naryth1ef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/b1naryth1ef/subscriptions","organizations_url":"https://api.github.com/users/b1naryth1ef/orgs","repos_url":"https://api.github.com/users/b1naryth1ef/repos","events_url":"https://api.github.com/users/b1naryth1ef/events{/privacy}","received_events_url":"https://api.github.com/users/b1naryth1ef/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/b1naryth1ef/disco","description":"Discord Python library for people that like to dance","fork":false,"url":"https://api.github.com/repos/b1naryth1ef/disco","forks_url":"https://api.github.com/repos/b1naryth1ef/disco/forks","keys_url":"https://api.github.com/repos/b1naryth1ef/disco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/b1naryth1ef/disco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/b1naryth1ef/disco/teams","hooks_url":"https://api.github.com/repos/b1naryth1ef/disco/hooks","issue_events_url":"https://api.github.com/repos/b1naryth1ef/disco/issues/events{/number}","events_url":"https://api.github.com/repos/b1naryth1ef/disco/events","assignees_url":"https://api.github.com/repos/b1naryth1ef/disco/assignees{/user}","branches_url":"https://api.github.com/repos/b1naryth1ef/disco/branches{/branch}","tags_url":"https://api.github.com/repos/b1naryth1ef/disco/tags","blobs_url":"https://api.github.com/repos/b1naryth1ef/disco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/b1naryth1ef/disco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/b1naryth1ef/disco/git/refs{/sha}","trees_url":"https://api.github.com/repos/b1naryth1ef/disco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/b1naryth1ef/disco/statuses/{sha}","languages_url":"https://api.github.com/repos/b1naryth1ef/disco/languages","stargazers_url":"https://api.github.com/repos/b1naryth1ef/disco/stargazers","contributors_url":"https://api.github.com/repos/b1naryth1ef/disco/contributors","subscribers_url":"https://api.github.com/repos/b1naryth1ef/disco/subscribers","subscription_url":"https://api.github.com/repos/b1naryth1ef/disco/subscription","commits_url":"https://api.github.com/repos/b1naryth1ef/disco/commits{/sha}","git_commits_url":"https://api.github.com/repos/b1naryth1ef/disco/git/commits{/sha}","comments_url":"https://api.github.com/repos/b1naryth1ef/disco/comments{/number}","issue_comment_url":"https://api.github.com/repos/b1naryth1ef/disco/issues/comments{/number}","contents_url":"https://api.github.com/repos/b1naryth1ef/disco/contents/{+path}","compare_url":"https://api.github.com/repos/b1naryth1ef/disco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/b1naryth1ef/disco/merges","archive_url":"https://api.github.com/repos/b1naryth1ef/disco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/b1naryth1ef/disco/downloads","issues_url":"https://api.github.com/repos/b1naryth1ef/disco/issues{/number}","pulls_url":"https://api.github.com/repos/b1naryth1ef/disco/pulls{/number}","milestones_url":"https://api.github.com/repos/b1naryth1ef/disco/milestones{/number}","notifications_url":"https://api.github.com/repos/b1naryth1ef/disco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/b1naryth1ef/disco/labels{/name}","releases_url":"https://api.github.com/repos/b1naryth1ef/disco/releases{/id}","deployments_url":"https://api.github.com/repos/b1naryth1ef/disco/deployments","created_at":"2016-08-02T00:29:23Z","updated_at":"2017-11-12T01:07:17Z","pushed_at":"2017-11-14T09:31:58Z","git_url":"git://github.com/b1naryth1ef/disco.git","ssh_url":"git@github.com:b1naryth1ef/disco.git","clone_url":"https://github.com/b1naryth1ef/disco.git","svn_url":"https://github.com/b1naryth1ef/disco","homepage":"https://b1naryth1ef.github.io/disco/","size":1392,"stargazers_count":113,"watchers_count":113,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":28,"mirror_url":null,"archived":false,"open_issues_count":7,"forks":28,"open_issues":7,"watchers":113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56"},"html":{"href":"https://github.com/b1naryth1ef/disco/pull/56"},"issue":{"href":"https://api.github.com/repos/b1naryth1ef/disco/issues/56"},"comments":{"href":"https://api.github.com/repos/b1naryth1ef/disco/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/b1naryth1ef/disco/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/b1naryth1ef/disco/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/b1naryth1ef/disco/statuses/1e97b700d782611f8df4653f59d689f92d450aec"}},"author_association":"NONE"}}
{"actor":{"display_login":"Alkali-Metal"}}