Add autoproxy functionality
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user