-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make basic birthday job and schedule work
- Loading branch information
Showing
8 changed files
with
92 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
using Quartz; | ||
using Quartz.Impl; | ||
using DSharpPlus; | ||
using KWiJisho.Commands; | ||
using KWiJisho.Data; | ||
using KWiJisho.Models; | ||
using Quartz; | ||
using System.Threading.Tasks; | ||
|
||
namespace KWiJisho.Scheduling | ||
{ | ||
[DisallowConcurrentExecution] | ||
/// <summary> | ||
/// Represents a Quartz.NET job that executes a birthday message task. | ||
/// </summary> | ||
internal class BirthdayJob : IJob | ||
{ | ||
/// <summary> | ||
private DiscordClient? _client; | ||
|
||
/// Executes the birthday message task as part of the Quartz.NET job. | ||
/// </summary> | ||
/// <param name="context">The execution context provided by Quartz.NET.</param> | ||
/// <returns>A <see cref="Task"/> representing the asynchronous execution of the job.</returns> | ||
public Task Execute(IJobExecutionContext context) => GiveBirthdayMessage(); | ||
public async Task Execute(IJobExecutionContext context) | ||
{ | ||
var dataMap = context.MergedJobDataMap; | ||
_client = (DiscordClient)dataMap.Get("DiscordClient"); | ||
|
||
await GiveBirthdayMessage(); | ||
} | ||
|
||
/// <summary> | ||
/// Sends a birthday message as an asynchronous task. | ||
/// </summary> | ||
/// <returns>A <see cref="Task"/> representing the asynchronous execution of the birthday message task.</returns> | ||
private static async Task GiveBirthdayMessage() => await Task.Run(() => ""); | ||
private async Task GiveBirthdayMessage() | ||
{ | ||
var server = Servers.Personal; | ||
|
||
// Getting guild by id. | ||
var serverGuild = await _client.GetGuildAsync(server.GuildId); | ||
|
||
// Getting channel by id. | ||
var discordChannel = serverGuild.GetChannel(server.GeneralChannelId); | ||
|
||
// Sending the birthday message. | ||
await CommandBirthday.SendBirthdayMessage(discordChannel, serverGuild, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters