Help with DiscordGameSDK in a C# project (no Unity)
I am currently trying to develop a plugin for a Unity game. For this I created a C# project, where I want to use Discord Rich Presence.
Here is my main cs file:
I have the five
discord_game_sdk.*
files within the root of my project directory and added the .cs
files for the SDK within a folder called DiscordGameSDK
. Somehow I still get the following error:
What am I missing? Any help appreciated :D33 Replies
you're missing some kind of package or using statement that has the
Discord
type in itI am following this: https://discord.com/developers/docs/game-sdk/getting-started#code-primer-nonunity-projects-csharp
And there they also tell me the same...
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Can you send a screenshot of what your solution looks like, including the
DiscordGameSDK
folder?It seems they're not distributing the SDK as a nuget
Yeah, loose C# files
Yeah
This is my current solution so far
There's no project file? No
Program.cs
?Where DRP.cs is my main cs
Well, see what namespace the
Discord
class is in, and reference that namespace
Everything else seems fine
If it was VS or Rider I'd tell you to autoimport those namespaces, but this looks like VS CodeI cna switch to VS right now, may be easier it seems
Done, I switched (VS 2022)
In general, yes, you should only use VS Code if you have a gun to your head and your family is held hostage
I code in other languages as well, for which VS Code fits my needs more 😅
It looks like
Discord
is in the Discord
namespace, inside Core.cs
And to use it I have to build my project?
You need to reference the namespace
using Namespace.Bla.Bla.Bla
Then you can use classes that reside in Namespace.Bla.Bla.Bla
namespaceBut I already tried that and it never works. I tried referencing it via the folder, doesn't work. There is also no highlighting of any available namespaces at all. I tried manually adding it inside my csproj file (via Reference with HintPath), didn't weork either.
Not getting proper autocomplete, that sounds like misconfigured VSC
Or just VSC being VSC
Make sure you have DevKit installed
I am suing VS 2022 now tho, since it should be better for .NET/C# dev
Also many people were suggesting "Right Click > Add Existing Item" or similar to fix this, but I don't even have these options at all...
tested it on my machine and it works fine if I just add the folder
all I did was copy + paste the files
I don't even have the dependencies fiels, like you do... EVen after copy-pasting the files via windows explorer again...
At this point I maybe should just create a new project and try again...
all I did was right-click my project (
DiscordTest
-> New Folder
)
then copy + pasted the .cs
files into the new folderI did the same...
it detects them automatically (or at least should)
this is in a new console app
not sure
A new console app with c#, right?
that's all I used, yeah
Yeah, trying it out as well... Just reinstalling VS as well, just to be sure that I don't miss anything...
rofl seriously?
... though I guess it would mostly be used by Unity devs