{"action":"created","issue":{"url":"https://api.github.com/repos/teamreflex/DiscordPHP/issues/167","repository_url":"https://api.github.com/repos/teamreflex/DiscordPHP","labels_url":"https://api.github.com/repos/teamreflex/DiscordPHP/issues/167/labels{/name}","comments_url":"https://api.github.com/repos/teamreflex/DiscordPHP/issues/167/comments","events_url":"https://api.github.com/repos/teamreflex/DiscordPHP/issues/167/events","html_url":"https://github.com/teamreflex/DiscordPHP/issues/167","id":184103057,"number":167,"title":"Send message without event","user":{"login":"judahnator","id":8620392,"avatar_url":"https://avatars.githubusercontent.com/u/8620392?v=3","gravatar_id":"","url":"https://api.github.com/users/judahnator","html_url":"https://github.com/judahnator","followers_url":"https://api.github.com/users/judahnator/followers","following_url":"https://api.github.com/users/judahnator/following{/other_user}","gists_url":"https://api.github.com/users/judahnator/gists{/gist_id}","starred_url":"https://api.github.com/users/judahnator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judahnator/subscriptions","organizations_url":"https://api.github.com/users/judahnator/orgs","repos_url":"https://api.github.com/users/judahnator/repos","events_url":"https://api.github.com/users/judahnator/events{/privacy}","received_events_url":"https://api.github.com/users/judahnator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-19T23:54:44Z","updated_at":"2016-10-20T00:07:58Z","closed_at":null,"body":"I can send messages just fine as a response to the 'message' event, but cannot seem to send a message outside of that.\r\n\r\nI have tried two different things.\r\n\r\nThe first is this:\r\n```php\r\n$discord = new Discord\\Discord([\r\n  'token' => env('BOT_TOKEN')\r\n]);\r\n\r\n$discord->factory(Discord\\Parts\\Channel\\Channel::class, [\r\n  'id' => 'CHANNEL_ID'\r\n])->sendMessage('test'))\r\n```\r\nIf I dump the return value of the ->sendMessage function it returns a promise object that looks like this:\r\n```php\r\nReact\\Promise\\Promise {#872\r\n  -canceller: null\r\n  -result: null\r\n  -handlers: []\r\n  -progressHandlers: []\r\n  -requiredCancelRequests: 0\r\n  -cancelRequests: 0\r\n}\r\n```\r\n\r\nThis wouldn't be a problem, if the other method mentioned in issue #132 didnt also seem broken.\r\nHere is the code I tried:\r\n```php\r\n$discord = new Discord\\Discord([\r\n  'token' => env('BOT_TOKEN')\r\n]);\r\n\r\n$guild = $discord->guilds->get('id', 'GUILD_ID'); // <-- breaks here\r\n$channel = $guild->channels->get('id', 'CHANNEL_ID');\r\n\r\n$channel->sendMessage('my message here');\r\n```\r\n\r\nWhen debugging it would appear that $discord->guilds returns null, so calling \"->get()\" on it results in a fatal error.\r\n\r\nIm a bit confused because these operations seem to work a bit later down inside of the \"->on('message')\" event.\r\n\r\nAny ideas? I can't seem to find anything in the docs to say i'm doing it wrong.\r\n"},"comment":{"url":"https://api.github.com/repos/teamreflex/DiscordPHP/issues/comments/254975496","html_url":"https://github.com/teamreflex/DiscordPHP/issues/167#issuecomment-254975496","issue_url":"https://api.github.com/repos/teamreflex/DiscordPHP/issues/167","id":254975496,"user":{"login":"Tekner","id":4205587,"avatar_url":"https://avatars.githubusercontent.com/u/4205587?v=3","gravatar_id":"","url":"https://api.github.com/users/Tekner","html_url":"https://github.com/Tekner","followers_url":"https://api.github.com/users/Tekner/followers","following_url":"https://api.github.com/users/Tekner/following{/other_user}","gists_url":"https://api.github.com/users/Tekner/gists{/gist_id}","starred_url":"https://api.github.com/users/Tekner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tekner/subscriptions","organizations_url":"https://api.github.com/users/Tekner/orgs","repos_url":"https://api.github.com/users/Tekner/repos","events_url":"https://api.github.com/users/Tekner/events{/privacy}","received_events_url":"https://api.github.com/users/Tekner/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T00:07:58Z","updated_at":"2016-10-20T00:07:58Z","body":"It has to be inside of an event, but it doesn't have to be inside of the message event. Add that code inside of $discord->on('ready', ...) and it should work. Everything has to run from a discord event in order for it to function correctly as far as I am able to discern."}}
{"actor":{"display_login":"Tekner"}}