.setgame renamed to .setactivity and now supports custom activities (with no playing in front of the text)
This commit is contained in:
parent
05c03248c4
commit
2605351f5c
6 changed files with 80 additions and 59 deletions
|
@ -58,7 +58,7 @@ public sealed class PlayingRotateService : IEService, IReadyExecutor
|
||||||
: rotatingStatuses[index++];
|
: rotatingStatuses[index++];
|
||||||
|
|
||||||
var statusText = await _repService.ReplaceAsync(playingStatus.Status, new (client: _client));
|
var statusText = await _repService.ReplaceAsync(playingStatus.Status, new (client: _client));
|
||||||
await _selfService.SetGameAsync(statusText, (ActivityType)playingStatus.Type);
|
await _selfService.SetActivityAsync(statusText, (ActivityType)playingStatus.Type);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -491,14 +491,25 @@ public partial class Administration
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
[OwnerOnly]
|
[OwnerOnly]
|
||||||
public async Task SetGame(ActivityType type, [Leftover] string game = null)
|
public async Task SetActivity(ActivityType? type, [Leftover] string game = null)
|
||||||
{
|
{
|
||||||
// var rep = new ReplacementBuilder().WithDefault(Context).Build();
|
// var rep = new ReplacementBuilder().WithDefault(Context).Build();
|
||||||
|
|
||||||
var repCtx = new ReplacementContext(ctx);
|
var repCtx = new ReplacementContext(ctx);
|
||||||
await _service.SetGameAsync(game is null ? game : await repSvc.ReplaceAsync(game, repCtx), type);
|
await _service.SetActivityAsync(game is null ? game : await repSvc.ReplaceAsync(game, repCtx), type);
|
||||||
|
|
||||||
await Response().Confirm(strs.set_game).SendAsync();
|
await Response().Confirm(strs.set_activity).SendAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[OwnerOnly]
|
||||||
|
public Task SetActivity([Leftover] string game = null)
|
||||||
|
=> SetActivity(null, game);
|
||||||
|
|
||||||
|
public class SetActivityOptions
|
||||||
|
{
|
||||||
|
public ActivityType? Type { get; set; }
|
||||||
|
public string Game { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
|
|
|
@ -85,7 +85,8 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
|
|
||||||
autoCommands = uow.Set<AutoCommand>().AsNoTracking()
|
autoCommands = uow.Set<AutoCommand>()
|
||||||
|
.AsNoTracking()
|
||||||
.Where(x => x.Interval >= 5)
|
.Where(x => x.Interval >= 5)
|
||||||
.AsEnumerable()
|
.AsEnumerable()
|
||||||
.GroupBy(x => x.GuildId)
|
.GroupBy(x => x.GuildId)
|
||||||
|
@ -400,7 +401,10 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _client.SetGameAsync(data.Name, data.Link, data.Type);
|
if (data.Type is { } activityType)
|
||||||
|
await _client.SetGameAsync(data.Name, data.Link, activityType);
|
||||||
|
else
|
||||||
|
await _client.SetCustomStatusAsync(data.Name);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -408,7 +412,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public Task SetGameAsync(string game, ActivityType type)
|
public Task SetActivityAsync(string game, ActivityType? type)
|
||||||
=> _pubSub.Pub(_activitySetKey,
|
=> _pubSub.Pub(_activitySetKey,
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
|
@ -430,7 +434,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
public string Name { get; init; }
|
public string Name { get; init; }
|
||||||
public string Link { get; init; }
|
public string Link { get; init; }
|
||||||
public ActivityType Type { get; init; }
|
public ActivityType? Type { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,7 +449,12 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
|
||||||
{
|
{
|
||||||
await using var ctx = _db.GetDbContext();
|
await using var ctx = _db.GetDbContext();
|
||||||
var presentDbUsers = await ctx.GetTable<DiscordUser>()
|
var presentDbUsers = await ctx.GetTable<DiscordUser>()
|
||||||
.Select(x => new { x.UserId, x.Username, x.Discriminator })
|
.Select(x => new
|
||||||
|
{
|
||||||
|
x.UserId,
|
||||||
|
x.Username,
|
||||||
|
x.Discriminator
|
||||||
|
})
|
||||||
.Where(x => users.Select(y => y.Id).Contains(x.UserId))
|
.Where(x => users.Select(y => y.Id).Contains(x.UserId))
|
||||||
.ToArrayAsyncEF();
|
.ToArrayAsyncEF();
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,8 @@ setavatar:
|
||||||
- setav
|
- setav
|
||||||
setbanner:
|
setbanner:
|
||||||
- setbanner
|
- setbanner
|
||||||
setgame:
|
setactivity:
|
||||||
|
- setactivity
|
||||||
- setgame
|
- setgame
|
||||||
send:
|
send:
|
||||||
- send
|
- send
|
||||||
|
|
|
@ -813,12 +813,12 @@ setbanner:
|
||||||
params:
|
params:
|
||||||
- img:
|
- img:
|
||||||
desc: "The URL of the image file to be displayed as the bot's banner."
|
desc: "The URL of the image file to be displayed as the bot's banner."
|
||||||
setgame:
|
setactivity:
|
||||||
desc: Sets the bots game status to either Playing, Listening, or Watching.
|
desc: Sets the bots game status to a Custom, Playing, Listening, or Watching status.
|
||||||
ex:
|
ex:
|
||||||
- Playing with snakes.
|
- Just chilling
|
||||||
- Watching anime.
|
- Playing with canaries.
|
||||||
- Listening music.
|
- Listening music
|
||||||
params:
|
params:
|
||||||
- type:
|
- type:
|
||||||
desc: "The activity type determines whether the bot is engaged in a game, listening to audio, or watching a video."
|
desc: "The activity type determines whether the bot is engaged in a game, listening to audio, or watching a video."
|
||||||
|
|
|
@ -195,7 +195,7 @@
|
||||||
"srvr_banner_too_large": "Specified image is too large! Maximum size is 8MB.",
|
"srvr_banner_too_large": "Specified image is too large! Maximum size is 8MB.",
|
||||||
"srvr_banner_invalid_url": "Specified url is not valid. Make sure you're specifying a direct image url.",
|
"srvr_banner_invalid_url": "Specified url is not valid. Make sure you're specifying a direct image url.",
|
||||||
"set_channel_name": "New channel name set.",
|
"set_channel_name": "New channel name set.",
|
||||||
"set_game": "New game set!",
|
"set_activity": "New activity set!",
|
||||||
"set_stream": "New stream set!",
|
"set_stream": "New stream set!",
|
||||||
"set_topic": "New channel topic set.",
|
"set_topic": "New channel topic set.",
|
||||||
"shard_reconnecting": "Shard {0} reconnecting.",
|
"shard_reconnecting": "Shard {0} reconnecting.",
|
||||||
|
|
Loading…
Reference in a new issue