To run a C# bot (Discord.Net, DSharpPlus or any .NET library) on your bot server:
- Check the bot's card on Overview says .NET Bot; if not, on the Bot page, pane Code, click Change what runs next to Runtime and pick it.
- Pick the .NET version under Runtime on the Code pane.
- Upload your project with its
.csproj(the server builds it on every start), or your published files, in Files. - Paste your token on the Bot page, pane Discord, and click Connect.
- Press Start and watch Console.
1. Check the type
The bot's card on Overview says what runs, for example Discord bot - .NET Bot. If it says another language, on the Bot page, pane Code, click Change what runs next to Runtime (on a computer, the type label at the top of the page opens the same dialog) and pick .NET Bot. Your files stay unless you tick Delete my existing files and start clean. See How to switch your bot to another language.
2. Pick the .NET version
On the Bot page, pane Code, card How it runs, set Runtime: .NET 8 (recommended), or .NET 6, 9 or 10. Match it to TargetFramework in your project: net8.0 for .NET 8, net10.0 for .NET 10.
3. Upload your bot: two ways
A. Upload the project, the server builds it
- In Files, upload your
.csprojand source files. Leave out thebinandobjfolders. To upload a folder, zip it, upload the zip, tick it and click Unzip. - Leave Entry file empty to use the
.csprojin the main folder. If there are several, type the one to build, for exampleMyBot.csproj.
On every start the server runs dotnet publish in Release mode, then starts the result. The console says [PlayNHost] Building your bot (the first build downloads packages and can take a minute). A project with its own <AssemblyName> starts too: the server picks the built program that has a .runtimeconfig.json next to it. On a server set up before this worked, click Reinstall at the bottom of the Code pane once; your files stay.
B. Upload published files
- On your computer run
dotnet publish -c Release -o publish. - Upload everything in the
publishfolder to the main folder in Files. - Set Entry file to the
.dll, for exampleMyBot.dll, and click Save. Left empty, the server finds it from the.runtimeconfig.jsonfile next to it.
Published files start faster and nothing is built on the server, so all of your plan's memory goes to the bot.

Your code on GitHub? The .NET Bot type can download it: How to deploy and update your Discord bot from GitHub.
4. A small Discord.Net 3 project
MyBot.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.*" />
</ItemGroup>
</Project>
Program.cs
using Discord;
using Discord.WebSocket;
var client = new DiscordSocketClient(new DiscordSocketConfig { GatewayIntents = GatewayIntents.Guilds });
client.Log += msg => { Console.WriteLine(msg); return Task.CompletedTask; };
client.Ready += () => { Console.WriteLine($"Logged in as {client.CurrentUser}"); return Task.CompletedTask; };
await client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("DISCORD_TOKEN"));
await client.StartAsync();
await Task.Delay(Timeout.Infinite);
5. Paste the token and start
On the Discord pane, paste the token and click Connect. Your code reads it as DISCORD_TOKEN. Press Start and open Console. When Logged in as appears, the chip on Overview turns to Online in Discord.
How much memory a Discord.Net bot uses
We measured it on one of our own servers on 6 November 2026, in a throwaway container set up like a 1 GB bot plan, with a fake token that Discord refused. A minimal Discord.Net 3.20.2 bot on .NET 8 used about 76 MB of memory. Discord answered 1.6 s after the start, of which 1.1 s was the dotnet publish step the server runs on every start and 0.5 s the bot itself. .NET 8 on its own used 24 MB, and a DSharpPlus 5.0 nightly bot on .NET 10 used 69 MB. A bot that has connected and joined servers uses more, so check RAM on the Usage card after a day of real use. Memory is the resident memory 15 seconds after Discord's answer, the median of three runs after a warm-up run.
Discord.Net does not stop on a wrong token. LoginAsync checks only the token's format; StartAsync then connects in the background, reports Discord's refusal through the Log event as Discord.Net.HttpException: The server responded with error 401: 401: Unauthorized and tries again. Keep the client.Log line of the sample above: without it, a bot with a wrong token prints nothing and looks running.
Console lines you may see
| Line | What to do |
|---|---|
[PlayNHost] Your bot is not set up yet: no project or published dll was found. | Upload a .csproj or your published files to the main folder, or set Entry file. |
[PlayNHost] The build failed. Read the errors above, fix them and press Start. | The compiler errors are just above (lines with error CS). Fix them, upload again and press Start. |
NETSDK1045 in the build output | Your project targets a newer .NET than the Runtime you picked. Pick the matching one. |
Good to know
- Building takes memory. A project with many packages may not build on the smallest plan; publish on your computer instead (way B). See How much RAM does a Discord bot need.
- There is no Packages field for .NET: add NuGet packages to your
.csproj. - Keys and passwords go under Environment, read with
Environment.GetEnvironmentVariable: How to set environment variables and secrets.



