-
Notifications
You must be signed in to change notification settings - Fork 13
feat: implement automatic Discord.NET adapter/autoposter #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
DiscordBotsList.Api.Adapter.Discord.Net/DiscordBotsList.Api.Adapter.Discord.Net.csproj
Show resolved
Hide resolved
velddev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems incomplete
| public virtual Task RunAsync() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intended to be implemented by this class' child classes. In this case, SubmissionAdapter.
Adapter's role is to implement the actual Task loop that does the autoposting, regardless of Discord bot library-specific implementation. It implements the IAdapter interface which is from DiscordBotsList.Api.Objects.
SubmissionAdapter's role is to implement Discord.NET-specific operations, or in this case await api.UpdateBotServerCountAsync((await client.GetGuildsAsync()).Count);
SubmissionAdapter is lifted from the older version of the SDK, it was an internal class so I made it public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapter's role is to implement the actual Task loop that does the autoposting, regardless of Discord bot library-specific implementation. It implements the IAdapter interface which is from DiscordBotsList.Api.Objects.
Okay makes sense. I would recommend using a BackgroundWorker then. https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.backgroundworker?view=net-9.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These adapters were a part of the old version of the SDK, but an automatic implementation that does it did not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapter's role is to implement the actual Task loop that does the autoposting, regardless of Discord bot library-specific implementation. It implements the IAdapter interface which is from DiscordBotsList.Api.Objects.
Okay makes sense. I would recommend using a BackgroundWorker then. https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.backgroundworker?view=net-9.0
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| namespace DiscordBotsList.Api.Adapter.Discord.Net | ||
| { | ||
| public class Adapter : IAdapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't really understand what this does? Why not just use BackgroundWorker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
1777e31 to
128cbed
Compare
b492f68 to
0bcec1c
Compare
The following pull request is a toned down version of #29. This pull request focuses solely on adding an actual automatic adapter for Discord.NET (a.k.a. autoposter.)