Skip to content

Commit

Permalink
Allow for a custom status to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
OoLunar committed Jan 23, 2025
1 parent 672c57b commit d7c1f09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Configuration/DiscordConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using DSharpPlus.Entities;

namespace OoLunar.Tomoe.Configuration
{
Expand All @@ -10,5 +11,7 @@ public sealed record DiscordConfiguration
public string SupportInvite { get; init; } = "https://discord.gg/YCSTr2KGq6";
public string[] Processors { get; init; } = [];
public TimeSpan CachePrefixSlidingExpiration { get; init; } = TimeSpan.FromMinutes(5);
public string StatusText { get; init; } = "Looking to help out!";
public DiscordActivityType StatusType { get; init; } = DiscordActivityType.Custom;
}
}
20 changes: 20 additions & 0 deletions src/Events/Handlers/Ready.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.EventArgs;
using OoLunar.Tomoe.Configuration;
using DiscordConfiguration = OoLunar.Tomoe.Configuration.DiscordConfiguration;

namespace OoLunar.Tomoe.Events.Handlers
{
public sealed class ReadyEventHandler : IEventHandler<SessionCreatedEventArgs>
{
private readonly DiscordConfiguration _config;

public ReadyEventHandler(TomoeConfiguration config) => _config = config.Discord;

[DiscordEvent(DiscordIntents.None)]
public async Task HandleEventAsync(DiscordClient client, SessionCreatedEventArgs eventArgs)
=> await client.UpdateStatusAsync(new DiscordActivity(_config.StatusText, _config.StatusType));
}
}

0 comments on commit d7c1f09

Please sign in to comment.