discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.28k stars 737 forks source link

Modify Bot's Browser or Device #2645

Closed ModEverything closed 5 months ago

ModEverything commented 5 months ago

General Troubleshooting

Feature Request

Currently the browser and device for JDA is a static string with "JDA". Could a feature be added where you could modify the browser or device in the classes JDABuilder or WebSocketFactory?

protected void sendIdentify()
    {
        LOG.debug("Sending Identify-packet...");
        PresenceImpl presenceObj = (PresenceImpl) api.getPresence();
        DataObject connectionProperties = DataObject.empty()
            .put("os", System.getProperty("os.name"))
            .put("browser", "JDA")
            .put("device", "JDA");
           ...}

I think there could be a WebSocketDevice class, which has these values as default in the constructor. Then you could add some get/set methods for the browser or the device. Then one could customize the name of the browser and device to do things like display a mobile status by inserting "Discord iOS".

I have used JDA for a long time and really enjoy it. I can't wait for this to be a feature in the near future!

Example Use-Case

public static void main(String[] args) {
        // TODO Auto-generated method stub
        JDABuilder workshop = JDABuilder.createDefault(TOKEN, GatewayIntent.getIntents(3276799));
        workshop.setActivity(Activity.customStatus("Look! I'm on mobile!"));
        workshop.addEventListeners(new CommandManager());
                workshop.setWebsocketFactory(new WebSocketFactory().setWebSocketDevice(new WebSocketDevice().setBrowser("Discord iOS")));
        workshop.build();
    }
duncte123 commented 5 months ago

That's supposed to be "JDA", as Discord's documentation states: https://discord.com/developers/docs/topics/gateway-events#identify-identify-connection-properties

MinnDevelopment commented 5 months ago

We follow the API requirements. Changing this is not an official feature.