I saw that NotSoBot has his status as online on mobile, is there a way that I can do that in discord.js?
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" }} });
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' } },
});
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.
ws:
in my Constants.js
file? –
Schoolbag 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.
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!
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`
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]
$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 © 2022 - 2024 — McMap. All rights reserved.