Giter Site home page Giter Site logo

Comments (15)

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

Doesn't seem to be working on Linux either.

Uncaught Error: Could not call remote method 'setIcon'. Check that the method signature is correct. Underlying error: Error processing argument at index 0, conversion failure from /usr/share/icons/hicolor48x48/apps/steam.png
Underlying stack: TypeError: Error processing argument at index 0, conversion failure from /usr/share/icons/hicolor48x48/apps/steam.png
    at /opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:370:67
    at EventEmitter.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:249:27)
    at EventEmitter.emit (events.js:200:13)
    at WebContents.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/api/web-contents.js:342:29)
    at WebContents.emit (events.js:200:13)

    at /opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:373:21
    at EventEmitter.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:249:27)
    at EventEmitter.emit (events.js:200:13)
    at WebContents.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/api/web-contents.js:342:29)
    at WebContents.emit (events.js:200:13)

from khub.

Kyza avatar Kyza commented on August 16, 2024

Can you confirm that the PNG is actually a PNG and not a different format hiding in a PNG file?

from khub.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

Yes, it's a PNG.

/usr/share/icons/hicolor/48x48/apps/steam.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced

I noticed that the path in the error log is missing a slash even though it's there in the input field. 🤔

from khub.

Kyza avatar Kyza commented on August 16, 2024

While I try to figure out exactly why that slash is not there, could you try adding an extra slash where the single one is?

from khub.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

No error. Still not working.

from khub.

Kyza avatar Kyza commented on August 16, 2024

This is strange, I can even use this path on my Windows system.

/Users/Name/Desktop/discord.png

from khub.

Kyza avatar Kyza commented on August 16, 2024

Try this version and tell me what path it prints in the console.

CustomDiscordIcon.prototype.getSettingsPanel = function() {
  var settingsWrapper = document.createElement("div");
  settingsWrapper.setAttribute("style", "width; 100%; height: auto;");


  // Here is the toggle for using the guild and DM icons.
  // Checked   = valueChecked-m-4IJZ
  // Unchecked = valueUnchecked-2lU_20
  var useGuildIcon = document.createElement("div");
  useGuildIcon.setAttribute("id", "useGuildIcon");

  var useGuildIconText = document.createElement("div");
  useGuildIconText.setAttribute("id", "useGuildIconText");

  var useGuildIconInput = document.createElement("input");
  useGuildIconInput.setAttribute("id", "useGuildIconInput");

  useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
  useGuildIcon.setAttribute("tabindex", "0");
  useGuildIcon.setAttribute("style", "flex: 0 0 auto; width: 250px; margin-bottom: 10px;");
  useGuildIcon.onclick = () => {
    if (useGuildIcon.getAttribute("class") == "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX") {
      useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
      useGuildIconInput.setAttribute("checked", "false");
    } else {
      useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
      useGuildIconInput.setAttribute("checked", "true");
    }
    saveSettings();
  };
  // Make sure that the checkbox is set to the correct value when it is created.
  if (loadSettings().useGuildIcons) {
    useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
    useGuildIconInput.setAttribute("checked", "true");
  } else {
    useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
    useGuildIconInput.setAttribute("checked", "false");
  }

  useGuildIconText.innerHTML = "Use Guild & DM Icons";
  useGuildIconText.setAttribute("style", "position: absolute; text-align: center; width: 100%; height: 100%; line-height: 22.5px;");
  useGuildIconInput.setAttribute("class", "checkboxEnabled-CtinEn checkbox-2tyjJg da-checkboxEnabled da-checkbox");
  useGuildIconInput.setAttribute("type", "checkbox");
  useGuildIconInput.setAttribute("tabindex", "-1");
  useGuildIconInput.setAttribute("checked", "false");
  useGuildIconInput.setAttribute("style", "margin-left: auto; margin-right: auto;");
  useGuildIcon.appendChild(useGuildIconText);
  useGuildIcon.appendChild(useGuildIconInput);



  var iconPath = document.createElement("input");
  iconPath.setAttribute("id", "custom-icon-path");
  iconPath.setAttribute("placeholder", "Enter the path to the image.");
  iconPath.setAttribute("type", "text");
  iconPath.setAttribute("style", "width: 100%; height: 30px; border-width: 0px; border-radius: 10px; background-color: rgba(255, 255, 255, 0.7); padding-left: 10px; margin-bottom: 10px;");

  var errorHTML = "<br>Your image must use a standard format such as <strong>PNG or JPG</strong>.<br>Animated GIFs are not supported and never will be.<br>Your image can't be a URL to something online, it has to ba saved somewhere.";
  iconPath.oninput = () => {
    saveSettings();

    try {
			console.log(document.getElementById("custom-icon-path").value);
      win.setIcon(document.getElementById("custom-icon-path").value);
      removeError();
    } catch (e) {
      settingsWrapper.appendChild(createError(errorHTML));
    }
  };

  var title = document.createElement("h1");
  title.setAttribute("style", "font-size: 1.5em; margin-bottom: 20px;");
  title.innerHTML = `<strong>CustomDiscordIcon Settings</strong>`;
  settingsWrapper.appendChild(title);

  settingsWrapper.appendChild(useGuildIcon);
  settingsWrapper.appendChild(iconPath);
  iconPath.value = (loadSettings() == undefined ? "" : loadSettings().customImagePath);

  // Try setting the icon right away.
	setTimeout(() => {
		try {
			console.log(document.getElementById("custom-icon-path").value);
			win.setIcon(document.getElementById("custom-icon-path").value);
			removeError();
		} catch (e) {
			settingsWrapper.appendChild(createError(errorHTML));
		}
	}, 100);

  BdApi.showToast("CustomDiscordIcon: Your settings will be saved automatically.", {});

  return settingsWrapper;
};

from khub.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

You could have posted a patch instead of the entire file.

from khub.

Kyza avatar Kyza commented on August 16, 2024

I changed it, just replace the getSettingsPanel function.

from khub.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

Nothing in the logs. This is in the config file.

{
  "useGuildIcons": false,
  "customImagePath": "/usr/share/icons/hicolor/48x48/apps/steam.png"
}

Switching useGuildIcon to true, I get the same error but the path is /home/$USER/.config/BetterDiscord/plugins/icon.png. Normally, you should be saving this file in a temporary directory:

path.join(os.tmpdir(), 'CustomDiscordIcon.png')

from khub.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

Anyway, my guess is you simply can't modify the icon on Linux because it either uses a file from Discord's directory, or a file provided by the system's icon theme. Both of which are normally owned by root.

from khub.

Kyza avatar Kyza commented on August 16, 2024

That's possible, but it doesn't explain why the slash was missing from the path earlier.

I'll need more Linux users to confirm.

from khub.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

Yeah, I don't know about that one. ¯\_(ツ)_/¯

from khub.

Shinare-I avatar Shinare-I commented on August 16, 2024

I don't know what else to say, but as a linux user, I can confirm it does not work.
I am running Ubuntu 18.04 on Unity desktop environment

from khub.

ludmtn avatar ludmtn commented on August 16, 2024

Hello, I do not understand how to change the photo of Discord, can you help me? (I am on Windows so no problem)

from khub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.