question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I implemented this:

` DiscordRPC.client.SetPresence(new RichPresence() {

                            Details = "Details",
                            State = $"State",
                            Buttons = new Button()
                            {
                                Url = "https://google.com",
                                Label = "Discord Server",
                            },
                            Assets = new Assets()
                            {
                                LargeImageKey = "imakey",
                                LargeImageText = "text",
                                
                            }
                            
                            
                        });`

And im getting this error: Cannot implicitly convert type ‘DiscordRPC.Button’ to ‘DiscordRPC.Button[]’

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Lacheecommented, Sep 29, 2021

that is… one way to do it. However a better, cleaner way (that doesn’t rely on JSON serialization (seriously dont do that just create the object)) would be the example provided https://github.com/Lachee/discord-rpc-csharp/blob/master/DiscordRPC.Example/Program.cs#L108-L111

            new RichPresence()
            {
                Details = "A Basic Example",
                State = "In Game",
                Timestamps = Timestamps.FromTimeSpan(10),
                Buttons = new Button[]
                {
                    new Button() { Label = "Fish", Url = "https://lachee.dev/" }
                }
            }
2reactions
AndreZila01commented, Sep 28, 2021

@DeathlyBower959 I found one solution…

	DiscordRPC.Button[] btn = new DiscordRPC.Button[1];

	private void Discord(){

		client = new DiscordRpcClient(APPLICATION ID, -1);

		client.Initialize();
		string url = "https://google.com";
		string Botaria = "Botaria";
		btn[0] = JsonConvert.DeserializeObject<DiscordRPC.Button>("{\"Url\":\"" + url + "\", \"Label\":\"" + Botaria + "\"}");
		string temp = "";
		var rp = new RichPresence()
		{
			Details = "",
			State = "",
			Assets = new Assets()
			{
				SmallImageKey = "",
				LargeImageKey = "",
			},
			Buttons = btn,
		};

		rp.Timestamps = new Timestamps(start);
		client.SetPresence(rp);
	}
Read more comments on GitHub >

github_iconTop Results From Across the Web

C program a button to perform a task once when pressed ...
I am relatively new to c and the Raspberry Pi and am trying simple programs. What I would like is when the button...
Read more >
Button in C# - GeeksforGeeks
A Button is an essential part of an application, or software, or webpage. It allows the user to interact with the application or...
Read more >
Three simple button-LED c-programs
Three simple button-LED c-programs illustrating the use of macros. Here are three simple programs in c for the AVR tiny44 that all do...
Read more >
Press Me Button Game - C Language Programming
Press Me Button Game - C Language Programming. Press Me Button Game. Click here to open this program in Turbo C++ / ...
Read more >
Can I create a button in C without any Windows?
The real-world answer is that you will never create a button or a window in C yourself. You pick an operating system, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found