Code Monkey home page Code Monkey logo

dsharpplus's Introduction

Logo of DSharpPlus

DSharpPlus

An unofficial .NET wrapper for the Discord API, based off DiscordSharp, but rewritten to fit the API standards.

Nightly Build Status Discord Server NuGet NuGet Latest Nightly/Prerelease

Installing

You can install the library from following sources:

  1. All Nightly versions are available on Nuget as a pre-release. These are cutting-edge versions automatically built from the latest commit in the master branch in this repository, and as such always contains the latest changes. If you want to use the latest features on Discord, you should use the nightlies.

    Despite the nature of pre-release software, all changes to the library are held under a level of scrutiny; for this library, unstable does not mean bad quality, rather it means that the API can be subject to change without prior notice (to ease rapid iteration) and that consumers of the library should always remain on the latest version available (to immediately get the latest fixes and improvements). You will usually want to use this version.

  2. The latest stable release is always available on NuGet. Stable versions are released less often, but are guaranteed to not receive any breaking API changes without a major version bump.

    Critical bugfixes in the nightly releases will usually be backported to the latest major stable release, but only after they have passed our soak tests. Additionally, some smaller fixes may be infrastructurally impossible or very difficult to backport without "breaking everything", and as such they will remain only in the nightly release until the next major release. You should evaluate whether or not this version suits your specific needs.

  3. The library can be directly referenced from your csproj file. Cloning the repository and referencing the library is as easy as:

    git clone https://github.com/DSharpPlus/DSharpPlus.git DSharpPlus-Repo
    

    Edit MyProject.csproj and add the following line:

    <ProjectReference Include="../DSharpPlus-Repo/DSharpPlus/DSharpPlus.csproj" />

    This belongs in the ItemGroup tag with the rest of your dependencies. The library should not be in the same directory or subdirectory as your project. This method should only be used if you're making local changes to the library.

Documentation

The documentation for the latest stable version is available at dsharpplus.github.io.

Resources

The following resources apply only for the latest stable version of the library.

Tutorials

Example bots

I want to throw my money at you

If you want to give us some money as a thank you gesture, you can do so using one of these links:

Questions?

Come talk to us here:

DSharpPlus Chat

Alternatively, you could also join us in the Discord API chat at #dotnet_dsharpplus.

Discord API Chat

dsharpplus's People

Contributors

afroraydude avatar akiraveliara avatar bond-009 avatar cabbageadi avatar drcreo avatar dubyadude avatar dwaffles avatar emzi0767 avatar giggitybyte avatar iderp avatar inftord avatar jeffreyladd avatar kiritsu avatar knightking100 avatar kob-kirito avatar kuylar avatar lachee avatar lulalaby avatar mckenon avatar naamloos avatar neuheit avatar nick-strohm avatar oolunar avatar patrickbkt avatar plerx2493 avatar quahu avatar suicvne avatar uwx avatar velvettoroyashi avatar wamwoowam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dsharpplus's Issues

Audit Logs

We should implement the ability to access audit logs.

Crashes when i do commands in private chat

So, I tried to do commands to the bot privately between me and him. But when i do that, the bot crashes.
image

                    DiscordRole r = e.Guild.Roles.Find(x => x.Name.Contains("VIP"));
                    if ((await e.Guild.GetMember(e.Message.Author.ID)).Roles.Contains(r.ID))
                    {
                        await e.Message.Respond("You dont have permissions for this command.");
                    }
                    else
                    {
                        await e.Message.Respond("You dont have permissions for this command.");
                    }
                }

SendFile() Access Issue

After successfully sending a file with SendFile it remains used by the process meaning it cannot be moved, deleted, edited, etc.

Integrate Reactions

afroraydude#5627 @ Discord API (Channel: dotnet_dsharpplus) reported:

Reactions integration

Error from Discord

Error: 736621096
User: afroraydude#5627
Time: 10/28/2016 1:52:08 PM
Message:

Reaction Integration

InteractivityExtension.Split missing end

InteractivityExtension.Split cuts off the end of text. I replaced it with this and it works for me.

public static IEnumerable<string> Split(this string str, int chunkSize)
{
    var len = str.Length;
    var i = 0;

    while (i < len)
    {
        var size = Math.Min(len - i, chunkSize);
        yield return str.Substring(i, size);
        i += size;
    }
}

Missing message pin events

We appear to be missing event handlers for the message pin/unpin and pin update events. We should implement them.

Selfbots

Since there were many changes to library's internals recently, selfbots should be checked out and fixed if necessary.

Consider not removing reactions in paginated messages

It's easy to get rate limited when removing the reactions, also it requires the "Manage Messages" permission which might worry some server admins. Instead we could treat the MessageReactionAdd and MessageReactionRemove as "click" events, both being able to switch the page.

Using current master on Windows 7 (fast fix)

Hey. I've come up with a quick solution to work with your library on Windows 7 on master branch and would like to share. How would like it to be contributed? Patch? Pull request? My weird idea is to currently maintain master-websocket4net branch and update it with master branch from time to time. Not super convenient, but that's what I'm currently using right now :)

Cheers!

[Suggestion]GetMessagesAsync

could we have the ability to get all messages since a certain date in a discord channel? i think that would be amazing.
Thanks in advance

IsBot property fails. Always returns false.

I believe this is because of this line:
[JsonProperty("is_bot", NullValueHandling = NullValueHandling.Ignore)]
I think it's supposed to be "bot" only according to Discord's documentation.

[Suggestion] Send embed using client.SendMessage()

Currently, I think the only way to send an embed is (DiscordClient is client in this example)

e.Channel.SendMessage("", false, embed).

Maybe we can get client.SendMessage(e.Channel.ID, "", false, embed)?

The given key was not present in the dictionary

This part of the code is giving me an error exception
if (!e.Channel.IsPrivate)
{
if(client.Guilds[e.Guild.ID].Members.Find(x => x.User.ID == e.Message.Author.ID).Roles.Contains(248495023132246017))
{
do stuff here
}
}

oz5wrql

SendPaginatedMessage evaluates the IEnumerable multiple times

This can be bad for performance depending on what the actual type is. It could be a LINQ query and in that case the query will run every time something like First(), Count(), or ToArray() is used.

Should just eagerly ToList() at the start of the method and use that instead.

Error from Discord

Error: 428367488
User: @189199638450929664
Time: 10/14/2016 8:12:45 PM
Message:

testitonemoretime

Error from Discord

Error: 267321056
User: @189199638450929664
Time: 10/14/2016 7:48:00 PM
Message:

test

NullRefException using Commands

Hey man,

Been using your lib for a bit now but I can't get my head around an issue I'm having when following your tutorials. I think they might be out of date or maybe there is a bug.

DiscordClient _client = new DiscordClient(new DiscordConfig()
{
       Token = "qsdfqsdf.qsdf.qsdf",
       AutoReconnect = true
});

_client.MessageCreated += async (e) =>
{
    if (!e.Message.Author.IsBot)
    {
          if (e.Message.Content.StartsWith("!hello"))
          await e.Channel.SendMessage($"Hello, {e.Message.Author.Username}");
     }
};

var c = new CommandConfig
{
    Prefix = "!",
    SelfBot = false
};

_client.UseCommands(c);

_client.AddCommand("hello", async (e) =>
{
      await e.Message.Parent.SendMessage($"Hello, {e.Message.Author.Mention}");
});

_client.Connect();
Console.ReadLine();

I get the following exception :
{"Method not found: 'DSharpPlus.DiscordMessage DSharpPlus.MessageCreateEventArgs.get_Message()'."}
System.MissingMethodException

And it happens as soon as a message is sent (not specifically with the prefix, just any message).

I'm guessing I'm just using the lib like a retard but I couldn't find a working scenario, could you possibly send some love to make it work ? :D

Thanks man

DiscordClient.cs InternalModifyGuidRole

May have found a typo in the InternalModifyGuildRole method in DiscordClient.cs.
Looks like a missing "/", didn't look into whether this should be fixed on the line (2459 in github) or somewhere else.

Current: string url = Utils.GetAPIBaseUri() + Endpoints.Guilds + "/" + guild_id + Endpoints.Roles + role_id;
Fixed: string url = Utils.GetAPIBaseUri() + Endpoints.Guilds + "/" + guild_id + Endpoints.Roles + "/" + role_id;

InternalGetMessages can't get more than 50 messages

GET request don't support payloads (.NET), though it has to for Discord's API. The Get Channel Messages endpoint requires a payload with a message ID and a limit. Neither of these can be filled in as .NET doesn't support this. We have two possible solutions.

  1. Keep it like this, limited to only the 50 latest messages
  2. 3rd party library for webrequests

So, what are we going to do? Any other suggestions?

Discord: "changing a..."

Naamloos#2887 @ Naamloos' chat (Channel: dsharpplus) reported:

changing avatar throws exception

Discord: "test issue..."

Naamloos#2887 @ Naamloos' chat (Channel: dsharpplus_dev) reported:

test issue reporting github stuff

Finishing touches on CNext

Before we release, we should put some finishing touches on CNext:

  • Implement proper [RequireOwner] attribute.
  • Implement proper [RequirePermission(Permission)] attribute. It should also have an option to automatically deny or allow in DMs.
  • Implement case insensitivity.
  • Implement [RemainingText] attribute
  • Make string splitter ignore any escape other than `, ", and whitespace.
  • Integrate string splitter with type converter.
  • Perhaps sudo functionality.

CommandContext.Guild.Roles is null

Was trying to make a command that lists a server's roles, but accessing ctx.Guild.Roles always throws a NullReferenceException... (EnableDms is false)

Discord: "email pass..."

Naamloos#2887 @ Discord API (Channel: dotnet_dsharpplus) reported:

email pass endpoint was removed. Make obsolete.

The big TODO list

So @Emzi0767 gave me some ideas for future versions of the library. These ideas should further improve the library in a lot of ways. I'm excited!

Here's a "little" checklist:

  • Incoming voice
  • Organize class members so that they are not all over the place, but are ordered according to some key. No effect on end-users, and will make maintenance easier.
  • Make all entities immutable, and perform mutation via events only. This is potentially mildly breaking, but it will also eliminate some weird cases.
  • Implement a message cache.
  • Abstract data structures. This will make maintenance infinitely easier. No effect on end-users.
  • Port VoiceNext to 2.x
  • .SetMute and .SetDeaf methods for DiscordMembers
  • Multi file uploading (to one message ofc)
  • Settle on argument naming. I'm in favour of snake_case. Shouldn't affect compatiblity.
  • Setting on private field naming. Ditto as above.
  • Rename all awaitable methods to ...Async(). This could be potentially breaking, but it'd help reduce confusion by making it clear what needs to be awaited and what doesn't.
  • Split the websocket and REST parts of the client for API communication. No effect on end-user, but will make classes smaller and easier to maintain.
  • make DiscordMember inherit from DiscordUser rather than wrap it. This is going to make working with members infinitely easier.
  • Docs overhaul
  • Command overhaul
  • More example bots
  • Support for different .NET versions, including .NET core
  • Discord character limits
  • Fix caches
  • Sharding support
  • Autosharding support

As emzi stated, the lib has grown quite a bit, and its code organization is messy.

If any of you have any other ideas, leave them as comments.
Also: if anything listed gets implemented, also leave a comment so i can edit the main message.

Thank you

Bot is duplicating Messages

If my Bot starts at all; I write a test message but it´s getting duplicated. (and then is going to crash.)

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.