Compare commits

...

4 commits

6 changed files with 280 additions and 249 deletions
src/EllieBot
Modules
strings

View file

@ -51,12 +51,9 @@ public sealed class HangmanService : IHangmanService, IExecNoCommand
} }
public ValueTask<bool> StopHangman(ulong channelId) public ValueTask<bool> StopHangman(ulong channelId)
{
lock (_locker)
{ {
if (_hangmanGames.TryRemove(channelId, out _)) if (_hangmanGames.TryRemove(channelId, out _))
return new(true); return new(true);
}
return new(false); return new(false);
} }
@ -66,8 +63,11 @@ public sealed class HangmanService : IHangmanService, IExecNoCommand
public async Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg) public async Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg)
{ {
if (_hangmanGames.ContainsKey(msg.Channel.Id)) if (!_hangmanGames.ContainsKey(msg.Channel.Id))
{ {
return;
}
if (string.IsNullOrWhiteSpace(msg.Content)) if (string.IsNullOrWhiteSpace(msg.Content))
return; return;
@ -108,7 +108,6 @@ public sealed class HangmanService : IHangmanService, IExecNoCommand
await SendState((ITextChannel)msg.Channel, msg.Author, msg.Content, state); await SendState((ITextChannel)msg.Channel, msg.Author, msg.Content, state);
} }
}
private Task<IUserMessage> SendState( private Task<IUserMessage> SendState(
ITextChannel channel, ITextChannel channel,

View file

@ -322,17 +322,29 @@ public sealed partial class Help : EllieModule<HelpService>
var transformed = g var transformed = g
.Select(x => .Select(x =>
{ {
var prepend = string.Empty;
var isOwnerOnly = x.Preconditions.Any(x => x is OwnerOnlyAttribute);
if (isOwnerOnly)
prepend = " \\👑";
//if cross is specified, and the command doesn't satisfy the requirements, cross it out //if cross is specified, and the command doesn't satisfy the requirements, cross it out
if (opts.View == CommandsOptions.ViewType.Cross) if (opts.View == CommandsOptions.ViewType.Cross)
{ {
return $"{(succ.Contains(x) ? "" : "")} {prefix + x.Aliases[0]}"; var outp = $"{(succ.Contains(x) ? "" : "")} {prefix + x.Aliases[0]}";
return prepend + outp;
} }
var output = prefix + x.Aliases[0];
if (x.Aliases.Count == 1) if (x.Aliases.Count > 1)
return prefix + x.Aliases[0]; output += " | " + prefix + x.Aliases[1];
return prefix + x.Aliases[0] + " | " + prefix + x.Aliases[1]; if (opts.View == CommandsOptions.ViewType.All)
return prepend + output;
return output;
}); });
embed.AddField(g.Key, "" + string.Join("\n", transformed) + "", true); embed.AddField(g.Key, "" + string.Join("\n", transformed) + "", true);
@ -347,7 +359,9 @@ public sealed partial class Help : EllieModule<HelpService>
{ {
var groupName = smc.Data.Values.FirstOrDefault(); var groupName = smc.Data.Values.FirstOrDefault();
var mdl = _cmds.Modules.FirstOrDefault(x var mdl = _cmds.Modules.FirstOrDefault(x
=> string.Equals(x.Name.Replace("Commands", ""), groupName, StringComparison.InvariantCultureIgnoreCase)); => string.Equals(x.Name.Replace("Commands", ""),
groupName,
StringComparison.InvariantCultureIgnoreCase));
await smc.DeferAsync(); await smc.DeferAsync();
await Group(mdl); await Group(mdl);
} }

View file

@ -201,12 +201,17 @@ public partial class Utility
message, message,
ReminderType.User); ReminderType.User);
var eb = CreateEmbed()
.WithOkColor()
.WithAuthor(ctx.User)
.WithTitle(GetText(strs.reminder_created))
.AddField(GetText(strs.who_where), !isPrivate ? $"<#{targetId}>" : ctx.User.Username, true)
.AddField(GetText(strs.when), TimestampTag.FromDateTime(time, TimestampTagStyles.Relative), true)
.AddField(GetText(strs.date2), TimestampTag.FromDateTime(time, TimestampTagStyles.ShortDateTime), true)
.WithDescription(message);
await Response() await Response()
.Confirm($"\u23f0 {GetText(strs.remind2( .Embed(eb)
Format.Bold(!isPrivate ? $"<#{targetId}>" : ctx.User.Username),
Format.Bold(message),
TimestampTag.FromDateTime(DateTime.UtcNow.Add(ts), TimestampTagStyles.Relative),
TimestampTag.FormatFromDateTime(time, TimestampTagStyles.ShortDateTime)))}")
.SendAsync(); .SendAsync();
return true; return true;

View file

@ -112,12 +112,13 @@ public partial class Utility : EllieModule
return; return;
} }
var userNames = new List<IUser>(socketGuild.Users.Count / 100); var userNames = new List<IUser>(socketGuild.Users.Count / 100);
foreach (var user in socketGuild.Users) foreach (var user in socketGuild.Users)
{ {
if (user.Activities.Any(x => x.Name is not null && x.Name.ToUpperInvariant() == game)) var activity = user.Activities.FirstOrDefault(x => x.Name is not null && x.Name.ToUpperInvariant() == game);
if (activity is not null)
{ {
game = activity.Name;
userNames.Add(user); userNames.Add(user);
} }
} }
@ -129,6 +130,9 @@ public partial class Utility : EllieModule
.PageSize(20) .PageSize(20)
.Page((names, _) => .Page((names, _) =>
{ {
var eb = CreateEmbed()
.WithTitle(GetText(strs.whos_playing_game(userNames.Count, game)));
if (names.Count == 0) if (names.Count == 0)
{ {
return CreateEmbed() return CreateEmbed()
@ -136,8 +140,7 @@ public partial class Utility : EllieModule
.WithDescription(GetText(strs.nobody_playing_game)); .WithDescription(GetText(strs.nobody_playing_game));
} }
var eb = CreateEmbed() eb = eb.WithOkColor();
.WithOkColor();
var users = names.Join('\n'); var users = names.Join('\n');
@ -646,7 +649,7 @@ public partial class Utility : EllieModule
[Ratelimit(3600)] [Ratelimit(3600)]
public async Task SaveChat(int cnt) public async Task SaveChat(int cnt)
{ {
if (cnt > 1000) if (!_creds.IsOwner(ctx.User) && cnt > 1000)
return; return;
var msgs = new List<IMessage>(cnt); var msgs = new List<IMessage>(cnt);

View file

@ -378,8 +378,8 @@ sargroupdelete:
desc: "The number of the group to delete." desc: "The number of the group to delete."
sarexclusive: sarexclusive:
desc: |- desc: |-
Toggles whether self-assigned roles are exclusive. Toggles the sar group as exclusive.
While enabled, users can only have one self-assignable role per group. While enabled, users can only have one self-assignable role from that group.
ex: ex:
- '1' - '1'
params: params:
@ -418,7 +418,11 @@ iamnot:
- role: - role:
desc: "The role to remove." desc: "The role to remove."
expradd: expradd:
desc: 'Add an expression with a trigger and a response. Bot will post a response whenever someone types the trigger word. Running this command in a server requires the Administrator permission. Running this command in DM is Bot Owner only and adds a new global expression. Guide [here](<https://docs.elliebot.net/ellie/features/expressions/>)' desc: |-
Add an expression with a trigger and a response.
Bot will post a response whenever someone types the trigger word.
Running this command in a server requires the Administrator permission.
Running this command in DM is Bot Owner only and adds a new global expression.
ex: ex:
- '"hello" Hi there %user.mention%' - '"hello" Hi there %user.mention%'
params: params:
@ -427,7 +431,7 @@ expradd:
response: response:
desc: "The text of the message that shows up when a user types the trigger word or phrase." desc: "The text of the message that shows up when a user types the trigger word or phrase."
expraddserver: expraddserver:
desc: 'Add an expression with a trigger and a response in this server. Bot will post a response whenever someone types the trigger word. This command is useful if you want to lower the permission requirement for managing expressions by using `{0}dpo`. Guide [here](<https://docs.elliebot.net/ellie/features/expressions/>).' desc: 'Add an expression with a trigger and a response in this server. Bot will post a response whenever someone types the trigger word. This command is useful if you want to lower the permission requirement for managing expressions by using `{0}dpo`.'
ex: ex:
- '"hello" Hi there %user.mention%' - '"hello" Hi there %user.mention%'
params: params:
@ -892,7 +896,9 @@ send:
text: text:
desc: "The recipient's preferred format for the message, such as plain text or formatted text with images and links." desc: "The recipient's preferred format for the message, such as plain text or formatted text with images and links."
savechat: savechat:
desc: Saves a number of messages to a text file and sends it to you. desc: |-
Saves a number of messages to a text file and sends it to you.
Max is 1000, unless you're the bot owner.
ex: ex:
- 150 - 150
params: params:

View file

@ -621,7 +621,10 @@
"quote_deleted": "Quote #{0} deleted.", "quote_deleted": "Quote #{0} deleted.",
"quote_edited": "Quote Edited", "quote_edited": "Quote Edited",
"region": "Region", "region": "Region",
"remind2": "I will remind {0} to {1} {2} ({3})", "reminder_created": "Reminder Created",
"who_where": "Who / Where",
"when": "When",
"date2": "Date",
"remind_timely": "I will remind you about your timely reward {0}", "remind_timely": "I will remind you about your timely reward {0}",
"timely_button": "Click the button to claim your timely reward.", "timely_button": "Click the button to claim your timely reward.",
"remind_invalid": "Not a valid remind format. Remind must have a target, timer and a reason. Check the command list.", "remind_invalid": "Not a valid remind format. Remind must have a target, timer and a reason. Check the command list.",
@ -1203,5 +1206,6 @@
"userrole_icon_fail": "Failed to set the role icon.", "userrole_icon_fail": "Failed to set the role icon.",
"userrole_icon_invalid": "The role icon cannot be empty.", "userrole_icon_invalid": "The role icon cannot be empty.",
"userrole_hierarchy_error": "You can't assign or modify roles that are higher than or equal to your, or bots highest role.", "userrole_hierarchy_error": "You can't assign or modify roles that are higher than or equal to your, or bots highest role.",
"userrole_role_not_exists": "That role doesn't exist." "userrole_role_not_exists": "That role doesn't exist.",
"whos_playing_game": "{0} users are playing {1}"
} }