DiscordFeature 2.1.0
See the version list below for details.
dotnet add package DiscordFeature --version 2.1.0
NuGet\Install-Package DiscordFeature -Version 2.1.0
<PackageReference Include="DiscordFeature" Version="2.1.0" />
paket add DiscordFeature --version 2.1.0
#r "nuget: DiscordFeature, 2.1.0"
// Install DiscordFeature as a Cake Addin
#addin nuget:?package=DiscordFeature&version=2.1.0
// Install DiscordFeature as a Cake Tool
#tool nuget:?package=DiscordFeature&version=2.1.0
DiscordFeature
A tiny library for easily creating features for discord bots using Discord.Net.
Usage
using Discord;
using Discord.WebSocket;
using static Discord.Feature;
// Login to discord
DiscordSocketConfig config = new() { AlwaysDownloadUsers = true, MessageCacheSize = 1000 };
// Reads from a file called 'token.tok' where the discord bot token is stored
await LoginAsync(TokenType.Bot, File.ReadAllText("token.tok"), config);
// Prevents the application from closing until specific word is entered
await LogoutKeyword("exit");
Creating a new Feature
To create a new feature simply create a new class and have it inherit from 'Discord.Feature' or just 'Feature' if 'using Discord' is used.
using Discord;
using Discord.WebSocket;
internal class NewDiscordFeature : Feature
{
}
Finally you need to override the 'Init' method so that you can setup the Feature.
using Discord;
using Discord.WebSocket;
internal class NewDiscordFeature : Feature
{
public override void Init(in DiscordSocketClient client)
{
client.MessageReceived += Client_MessageReceived;
// Add more as needed
}
private Task Client_MessageReceived(SocketMessage arg)
{
Console.WriteLine(arg.Content);
return Task.CompletedTask;
}
}
And thats it, you don't need to create any instances for these features, they will be created automatically at runtime.
Project structure
To keep things nice and neat I recommend creating a new folder called 'Features' and in that create a folder for each new feature where you would then create your feature class and other files specific to that feature in it.
It should look like so.
https://raw.githubusercontent.com/TizzyT566/DiscordFeature/master/projectStructure.jpg
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Discord.Net (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.