Skip to content

yoshiask/Discord-UWP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord-UWP Build status

A Discord wrapper in C# compatible with UWP.

Basic Api Services

Api services that do not require authentication can be accessed by doing:

DiscordApiConfiguration config = new DiscordApiConfiguration
{
    BaseUrl = "https://discordapp.com/api"
};

BasicRestFactory basicRestFactory = new BasicRestFactory(config);

ILoginService loginService = basicRestFactory.GetLoginService();
IGatewayService gatewayService = basicRestFactory.GetGatewayService();

Authentication

Note: This is not the planned implantation of the Authentication layer, this is just a band-aid solution till time is found to work on it.

LoginRequest loginRequest = new LoginRequest
{
    Email = "EMAIL",
    Password = "PASSWORD"
};

LoginResult loginResult = await loginService.Login(loginRequest);

IAuthenticator authenticator = new DiscordAuthenticator(loginResult.Token);

Authenticated Api Services

AuthenticatedRestFactory authenticatedRestFactory = new AuthenticatedRestFactory(config, authenticator);

IUserService userService = authenticatedRestFactory.GetUserService();
IGuildService guildService = authenticatedRestFactory.GetGuildService(); 
IChannelService channelService = authenticatedRestFactory.GetChannelService();
IInviteService inviteService = authenticatedRestFactory.GetInviteService();

Gateway

To create a Gateway instance, you need a GatewayConfig and an IAuthenticator.

GatewayConfig config = await gatewayService.GetGatewayConfigAsync();

Gateway gateway = new Gateway(config, authenticator);

To connect just call:

await gateway.ConnectAsync();

Then events can be listened to as follows:

gateway.MessageCreated += (sender, e) => 
{ 
    Message message = e.EventPayload;
    // Handle message
};

Future Plans

  • Finish implementing all gateway events
  • Make authentication layer so it can securely store authentication state
  • Implement Voice
  • Remove Universal Windows dependencies and only depend on .NETCore

About

A Discord wrapper in C# compatible with UWP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%