Created
August 23, 2022 14:43
-
-
Save tibynx/02339f9eb7355e942b2191651e34acf7 to your computer and use it in GitHub Desktop.
This allows your discord bot to have a mobile status indicator. All you need to do is just import this into your main file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from discord.gateway import DiscordWebSocket | |
| async def identify(self): | |
| payload = { | |
| "op": self.IDENTIFY, | |
| "d": { | |
| "token": self.token, | |
| "properties": { | |
| "$os": "Discord iOS", | |
| "$browser": "Discord iOS", | |
| "$device": "iOS", | |
| "$referrer": "", | |
| "$referring_domain": "", | |
| }, | |
| "compress": True, | |
| "large_threshold": 250, | |
| }, | |
| } | |
| if self.shard_id is not None and self.shard_count is not None: | |
| payload["d"]["shard"] = [self.shard_id, self.shard_count] | |
| state = self._connection | |
| if state._activity is not None or state._status is not None: | |
| payload["d"]["presence"] = { | |
| "status": state._status, | |
| "game": state._activity, | |
| "since": 0, | |
| "afk": False, | |
| } | |
| if state._intents is not None: | |
| payload["d"]["intents"] = state._intents.value | |
| await self.call_hooks("before_identify", self.shard_id, initial=self._initial_identify) | |
| await self.send_as_json(payload) | |
| DiscordWebSocket.identify = identify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment