mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 06:47:56 +00:00
Add autoproxy functionality
This commit is contained in:
parent
57bc576de6
commit
83cfb3eb46
5 changed files with 186 additions and 11 deletions
|
|
@ -11,10 +11,12 @@ namespace PluralKit.Bot.Commands
|
|||
public class AutoproxyCommands
|
||||
{
|
||||
private IDataStore _data;
|
||||
private AutoproxyCacheService _cache;
|
||||
|
||||
public AutoproxyCommands(IDataStore data)
|
||||
public AutoproxyCommands(IDataStore data, AutoproxyCacheService cache)
|
||||
{
|
||||
_data = data;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
public async Task Autoproxy(Context ctx)
|
||||
|
|
@ -49,6 +51,7 @@ namespace PluralKit.Bot.Commands
|
|||
settings.AutoproxyMode = AutoproxyMode.Off;
|
||||
settings.AutoproxyMember = null;
|
||||
await _data.SetSystemGuildSettings(ctx.System, ctx.Guild.Id, settings);
|
||||
await _cache.FlushCacheForSystem(ctx.System, ctx.Guild.Id);
|
||||
await ctx.Reply($"{Emojis.Success} Autoproxy turned off in this server.");
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +68,7 @@ namespace PluralKit.Bot.Commands
|
|||
settings.AutoproxyMode = AutoproxyMode.Latch;
|
||||
settings.AutoproxyMember = null;
|
||||
await _data.SetSystemGuildSettings(ctx.System, ctx.Guild.Id, settings);
|
||||
await _cache.FlushCacheForSystem(ctx.System, ctx.Guild.Id);
|
||||
await ctx.Reply($"{Emojis.Success} Autoproxy set to latch mode in this server. Messages will now be autoproxied using the *last-proxied member* in this server.");
|
||||
}
|
||||
}
|
||||
|
|
@ -81,6 +85,7 @@ namespace PluralKit.Bot.Commands
|
|||
settings.AutoproxyMode = AutoproxyMode.Front;
|
||||
settings.AutoproxyMember = null;
|
||||
await _data.SetSystemGuildSettings(ctx.System, ctx.Guild.Id, settings);
|
||||
await _cache.FlushCacheForSystem(ctx.System, ctx.Guild.Id);
|
||||
await ctx.Reply($"{Emojis.Success} Autoproxy set to front mode in this server. Messages will now be autoproxied using the *current first fronter*, if any.");
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +98,7 @@ namespace PluralKit.Bot.Commands
|
|||
settings.AutoproxyMode = AutoproxyMode.Member;
|
||||
settings.AutoproxyMember = member.Id;
|
||||
await _data.SetSystemGuildSettings(ctx.System, ctx.Guild.Id, settings);
|
||||
|
||||
await _cache.FlushCacheForSystem(ctx.System, ctx.Guild.Id);
|
||||
await ctx.Reply($"{Emojis.Success} Autoproxy set to **{member.Name}** in this server.");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue