.serverinfo improved, updated changelog, added seconds to .convert

This commit is contained in:
Kwoth
2024-05-03 06:29:08 +00:00
parent 96ad5516d3
commit 6327e242ca
7 changed files with 75 additions and 61 deletions

View File

@@ -34,10 +34,13 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
- For self-hosters: - For self-hosters:
- Added `.sqlselectcsv` which will return results in a csv file instead of an embed. - Added `.sqlselectcsv` which will return results in a csv file instead of an embed.
- Added a page parameter to `.feedlist` - Added a page parameter to `.feedlist`
- Added seconds/sec/s to .convert command
### Changed ### Changed
- Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi` and `.sfl`) - Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi` and `.sfl`)
- `.send` command should work consistently and correctly now. You can have targets from other shards too. The usage has been changed. refer to `.h .send` for more info
- `.serverinfo` no longer takes a server name. It only takes an id or no arguments
- You can now target a different channel with .repeat, for example `.repeat #some-other 1h Hello every hour` - You can now target a different channel with .repeat, for example `.repeat #some-other 1h Hello every hour`
- `.cmds <module name>`, `.cmds <group name` and `.mdls` looks better / cleaner / simpler - `.cmds <module name>`, `.cmds <group name` and `.mdls` looks better / cleaner / simpler
- The bot will now send a discord Reply to every command - The bot will now send a discord Reply to every command
@@ -48,6 +51,8 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
- `.feed` should now correctly accept (and show) the message which can be passed as the third parameter - `.feed` should now correctly accept (and show) the message which can be passed as the third parameter
- `.say` will now correctly report errors if the user or the bot don't have sufficent perms to send a message in the targeted channel - `.say` will now correctly report errors if the user or the bot don't have sufficent perms to send a message in the targeted channel
- Fixed a bug in .invitelist not paginating correctly - Fixed a bug in .invitelist not paginating correctly
- `.serverinfo` will now correctly work for other shards
- `.send` will now correctly work for other shards
### Removed ### Removed

View File

@@ -33,7 +33,7 @@ public partial class Permissions
?? ""), ?? ""),
BlacklistType.User => Format.Code(i.ItemId.ToString()) BlacklistType.User => Format.Code(i.ItemId.ToString())
+ " " + " "
+ ((await _client.Rest.GetUserAsync(i.ItemId)) + ((_client.GetUser(i.ItemId))
?.ToString() ?.ToString()
?? ""), ?? ""),
BlacklistType.Server => Format.Code(i.ItemId.ToString()) BlacklistType.Server => Format.Code(i.ItemId.ToString())

View File

@@ -22,31 +22,25 @@ public partial class Utility
[Cmd] [Cmd]
[OwnerOnly] [OwnerOnly]
public Task ServerInfo([Leftover] string guildName) public Task ServerInfo(ulong guildId)
=> InternalServerInfo(guildName); => InternalServerInfo(guildId);
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task ServerInfo() public Task ServerInfo()
=> InternalServerInfo(); => InternalServerInfo(ctx.Guild.Id);
private async Task InternalServerInfo(string guildName = null) private async Task InternalServerInfo(ulong guildId)
{ {
var channel = (ITextChannel)ctx.Channel; var guild = (IGuild)_client.GetGuild(guildId)
guildName = guildName?.ToUpperInvariant(); ?? await _client.Rest.GetGuildAsync(guildId);
SocketGuild guild;
if (string.IsNullOrWhiteSpace(guildName))
guild = (SocketGuild)channel.Guild;
else
guild = _client.Guilds.FirstOrDefault(g => g.Name.ToUpperInvariant() == guildName.ToUpperInvariant());
if (guild is null) if (guild is null)
return; return;
var ownername = guild.GetUser(guild.OwnerId); var ownername = await guild.GetUserAsync(guild.OwnerId);
var textchn = guild.TextChannels.Count; var textchn = (await guild.GetTextChannelsAsync()).Count;
var voicechn = guild.VoiceChannels.Count; var voicechn = (await guild.GetVoiceChannelsAsync()).Count;
var channels = $@"{GetText(strs.text_channels(textchn))} var channels = $@"{GetText(strs.text_channels(textchn))}
{GetText(strs.voice_channels(voicechn))}"; {GetText(strs.voice_channels(voicechn))}";
var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(guild.Id >> 22); var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(guild.Id >> 22);
@@ -59,7 +53,7 @@ public partial class Utility
.WithTitle(guild.Name) .WithTitle(guild.Name)
.AddField(GetText(strs.id), guild.Id.ToString(), true) .AddField(GetText(strs.id), guild.Id.ToString(), true)
.AddField(GetText(strs.owner), ownername.ToString(), true) .AddField(GetText(strs.owner), ownername.ToString(), true)
.AddField(GetText(strs.members), guild.MemberCount.ToString(), true) .AddField(GetText(strs.members), (guild as SocketGuild)?.MemberCount ?? guild.ApproximateMemberCount, true)
.AddField(GetText(strs.channels), channels, true) .AddField(GetText(strs.channels), channels, true)
.AddField(GetText(strs.created_at), $"{createdAt:dd.MM.yyyy HH:mm}", true) .AddField(GetText(strs.created_at), $"{createdAt:dd.MM.yyyy HH:mm}", true)
.AddField(GetText(strs.roles), (guild.Roles.Count - 1).ToString(), true) .AddField(GetText(strs.roles), (guild.Roles.Count - 1).ToString(), true)
@@ -113,7 +107,9 @@ public partial class Utility
.AddField(GetText(strs.id), role.Id.ToString(), true) .AddField(GetText(strs.id), role.Id.ToString(), true)
.AddField(GetText(strs.created_at), $"{createdAt:dd.MM.yyyy HH:mm}", true) .AddField(GetText(strs.created_at), $"{createdAt:dd.MM.yyyy HH:mm}", true)
.AddField(GetText(strs.users), usercount.ToString(), true) .AddField(GetText(strs.users), usercount.ToString(), true)
.AddField(GetText(strs.color), $"#{role.Color.R:X2}{role.Color.G:X2}{role.Color.B:X2}", true) .AddField(GetText(strs.color),
$"#{role.Color.R:X2}{role.Color.G:X2}{role.Color.B:X2}",
true)
.AddField(GetText(strs.mentionable), role.IsMentionable.ToString(), true) .AddField(GetText(strs.mentionable), role.IsMentionable.ToString(), true)
.AddField(GetText(strs.hoisted), role.IsHoisted.ToString(), true) .AddField(GetText(strs.hoisted), role.IsHoisted.ToString(), true)
.WithOkColor(); .WithOkColor();
@@ -133,7 +129,8 @@ public partial class Utility
if (user is null) if (user is null)
return; return;
var embed = _sender.CreateEmbed().AddField(GetText(strs.name), $"**{user.Username}**#{user.Discriminator}", true); var embed = _sender.CreateEmbed()
.AddField(GetText(strs.name), $"**{user.Username}**#{user.Discriminator}", true);
if (!string.IsNullOrWhiteSpace(user.Nickname)) if (!string.IsNullOrWhiteSpace(user.Nickname))
embed.AddField(GetText(strs.nickname), user.Nickname, true); embed.AddField(GetText(strs.nickname), user.Nickname, true);
@@ -204,12 +201,14 @@ public partial class Utility
kvp.Value))); kvp.Value)));
} }
await Response().Embed(_sender.CreateEmbed() await Response()
.Embed(_sender.CreateEmbed()
.WithTitle(GetText(strs.activity_page(page + 1))) .WithTitle(GetText(strs.activity_page(page + 1)))
.WithOkColor() .WithOkColor()
.WithFooter(GetText( .WithFooter(GetText(
strs.activity_users_total(_cmdHandler.UserMessagesSent.Count))) strs.activity_users_total(_cmdHandler.UserMessagesSent.Count)))
.WithDescription(str.ToString())).SendAsync(); .WithDescription(str.ToString()))
.SendAsync();
} }
} }
} }

View File

@@ -422,8 +422,7 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
return; return;
await _sender.Response(chan) await _sender.Response(chan)
.Confirm( .Confirm(_strings.GetText(strs.level_up_global(user.Mention,
_strings.GetText(strs.level_up_global(user.Mention,
Format.Bold(newLevel.ToString())), Format.Bold(newLevel.ToString())),
guild.Id)) guild.Id))
.SendAsync(); .SendAsync();

View File

@@ -13,7 +13,7 @@ namespace NadekoBot.Common.Configs;
public sealed partial class BotConfig : ICloneable<BotConfig> public sealed partial class BotConfig : ICloneable<BotConfig>
{ {
[Comment("""DO NOT CHANGE""")] [Comment("""DO NOT CHANGE""")]
public int Version { get; set; } = 5; public int Version { get; set; } = 6;
[Comment(""" [Comment("""
Most commands, when executed, have a small colored line Most commands, when executed, have a small colored line

View File

@@ -437,9 +437,9 @@ remindlist:
- "1" - "1"
- "server 2" - "server 2"
serverinfo: serverinfo:
desc: "Shows info about the server the bot is on. If no server is supplied, it defaults to current one." desc: "Shows info about the server with the specified ID. The bot has to be on that server. If no server is supplied, it defaults to current one."
args: args:
- "Some Server" - "123123132233"
channelinfo: channelinfo:
desc: "Shows info about the channel. If no channel is supplied, it defaults to current one." desc: "Shows info about the channel. If no channel is supplied, it defaults to current one."
args: args:

View File

@@ -719,6 +719,17 @@
"UnitType": "time", "UnitType": "time",
"Modifier": 60.0 "Modifier": 60.0
}, },
{
"Triggers": [
"second",
"seconds",
"sec",
"secs",
"s"
],
"UnitType": "time",
"Modifier": 1
},
{ {
"Triggers": [ "Triggers": [
"year", "year",