How to make bot status show as "Online from Mobile"
Asked Answered
H

7

6

I saw that NotSoBot has his status as online on mobile, is there a way that I can do that in discord.js?

Honesty answered 26/2, 2020 at 10:18 Comment(0)
T
8

I understand this is old, but an easier method would be to add this where you define client/bot

const client = new Discord.Client({ ws: { properties: { $browser: "Discord iOS" }} });
Trace answered 16/11, 2020 at 18:5 Comment(1)
wait it's possible to do this without changing the src of discord.js? i never knewStoecker
D
3

In discord.js v13, when you instantiate the client you can provide the $browser inside ws properties:

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    // .. more intents as needed
  ],
  ws: { properties: { $browser: 'Discord iOS' } },
});

And in discord.js v14 it's just browser now:

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    // .. more intents as needed
  ],
  ws: { properties: { browser: 'Discord iOS' } },
});
Detailed answered 30/10, 2022 at 13:17 Comment(0)
A
2

This is undocumented but here you go nevertheless if you really want to do this you must go to the Constants.js file. Under the node_modules folder, either if you're using something like Visual Studio Code or just go directly to the file, navigate to "src", then "util", then find the Constants.js file. Once there scroll down until you see "ws:" it should look something like this:

  ws: {
    large_threshold: 250,
    compress: require('os').platform() !== 'browser',
    properties: {
      $os: process ? process.platform : 'discord.js',
      $browser: 'discord.js',
      $device: 'discord.js',
      $referrer: '',
      $referring_domain: '',
    },
    version: 6,
  },

Change

$browser: 'discord.js',

to

$browser: 'Discord iOS',

And then start your bot, it should have a small phone icon next to its avatar. Hope this helps.

Abad answered 26/2, 2020 at 17:34 Comment(1)
But what if I don't have ws: in my Constants.js file?Schoolbag
M
1

Solution for the latest version of discord.js at the moment ([email protected])

const { 
    DefaultWebSocketManagerOptions: { 
        identifyProperties 
    } 
} = require("@discordjs/ws");

identifyProperties.browser = "Discord Android"; // or "Discord iOS"

Please note: this approach is not documented and is not endorsed by Discord API and discord.js.

The code above modifies the browser property of the identifyProperties object. The value of the browser property should be the name of the library, according to the Discord API.

We change this property to "Discord Android" or "Discord iOS", thus getting the status "online from mobile". This is a dirty trick.

Mcneese answered 9/9, 2023 at 13:1 Comment(0)
K
1

I tried adding { ws: { properties: { browser: "Discord iOS" }} } or similar things into my code, however, it didn't work for me... Not in the latest discord.js v14 at least. Adding or removing the $ sign infront of browser didn't change things for me as well.

My solution: Import DefaultWebSocketManagerOptions and change the value from there as follows:

const { Client, DefaultWebSocketManagerOptions } = require('discord.js');

const client = new Client({
  intents: [
    // your intents here
  ]
});

DefaultWebSocketManagerOptions.identifyProperties.browser = 'Discord iOS'; // Sets it for EVERY new Client(...)

client.login(...);

Worked like a charm on my project and I don't have to change the contents of the node_modules folder like other people did. Hope this helps!

Kibbutz answered 30/1 at 23:20 Comment(0)
A
0

This is undocumented but here you go nevertheless if you really want to do this you must go to the Constants.js file. Under the node_modules folder, either if you're using something like Visual Studio Code or just go directly to the file, navigate to "src", then "util", then find the Option.js file. Once there scroll down until you see "ws:" it should look something like this: Go In

node_module/discord.js/src/utill/Options.js And Scroll Down You See

ws: {
  large_threshold: 250,
  compress: require('os').platform() !== 'browser',
  properties: {
    $os: process ? process.platform : 'discord.js',
    $browser: 'discord.js',
    $device: 'discord.js',
    $referrer: '',
    $referring_domain: '',
  },
  version: 6,
},

Change $browser: 'discord.js' to $browser: 'Discord Android'.
Or You Can Set Discord Ios

Or you can put this code on your main file

const Options = require('discord.js/src/util/Options.js');
Options.DefaultOptions.ws.properties.$browser = `Discord Android`
Aesthetics answered 1/7, 2022 at 1:23 Comment(0)
R
-1

Use this: Change the $browser

const client = new Discord.Client({ ws: { properties: { $browser: "Discord iOS" }} });

To browser:

const client = new Discord.Client({ ws: { properties: { browser: "Discord iOS" }} });

If you check the constants.js file, the sections are: ws > properties > browser, at no time is there a $

[discord.js v13, v14]

Rudolf answered 29/10, 2022 at 12:39 Comment(3)
Nope. In v13 it's $browser and in v14 there is no $ sign, so just browser. And in neither of those versions are these settings in the Constants.js file but the Options.js.Detailed
I've checked the files and tested if it works and if it works without the $ and fails with the $, you're wrong.Rudolf
Sure, sure... :) Or you've just misread something in my comment. I'm right though.Detailed

© 2022 - 2024 — McMap. All rights reserved.