mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-12-19 12:53:11 -05:00
- Fixed calls to SendAsync - they don't require EmbedBuilderService
- DmHelpText now uses smarttext and supports user-related placeholders
This commit is contained in:
@@ -469,7 +469,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
|
||||
text = rep.Replace(text);
|
||||
await ch.SendAsync(_eb, text, sanitizeAll: false);
|
||||
await ch.SendAsync(text, sanitizeAll: false);
|
||||
}
|
||||
else if (ids[1].ToUpperInvariant().StartsWith("U:", StringComparison.InvariantCulture))
|
||||
{
|
||||
@@ -480,7 +480,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
var ch = await user.GetOrCreateDMChannelAsync();
|
||||
text = rep.Replace(text);
|
||||
await ch.SendAsync(_eb, text);
|
||||
await ch.SendAsync(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task EditMessage(ICommandContext context, ITextChannel chanl, ulong messageId, string text)
|
||||
public async Task EditMessage(ICommandContext context, ITextChannel chanl, ulong messageId, string input)
|
||||
{
|
||||
var msg = await chanl.GetMessageAsync(messageId);
|
||||
|
||||
@@ -167,23 +167,10 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
.WithDefault(context)
|
||||
.Build();
|
||||
|
||||
if (CREmbed.TryParse(text, out var crembed))
|
||||
{
|
||||
rep.Replace(crembed);
|
||||
await umsg.ModifyAsync(x =>
|
||||
{
|
||||
x.Embed = crembed.ToEmbed(_eb).Build();
|
||||
x.Content = crembed.PlainText?.SanitizeMentions() ?? "";
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await umsg.ModifyAsync(x =>
|
||||
{
|
||||
x.Content = text.SanitizeMentions();
|
||||
x.Embed = null;
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
var text = SmartText.CreateFrom(input);
|
||||
text = rep.Replace(text);
|
||||
|
||||
await umsg.EditAsync(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace NadekoBot.Modules.Help.Services
|
||||
private readonly DiscordPermOverrideService _dpos;
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly Replacer _rep;
|
||||
|
||||
public HelpService(CommandHandler ch,
|
||||
IBotStrings strings,
|
||||
@@ -36,12 +35,6 @@ namespace NadekoBot.Modules.Help.Services
|
||||
_dpos = dpos;
|
||||
_bss = bss;
|
||||
_eb = eb;
|
||||
|
||||
|
||||
_rep = new ReplacementBuilder()
|
||||
.WithOverride("%prefix%", () => _bss.Data.Prefix)
|
||||
.WithOverride("%bot.prefix%", () => _bss.Data.Prefix)
|
||||
.Build();
|
||||
}
|
||||
|
||||
public Task LateExecute(IGuild guild, IUserMessage msg)
|
||||
@@ -51,11 +44,17 @@ namespace NadekoBot.Modules.Help.Services
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(settings.DmHelpText) || settings.DmHelpText == "-")
|
||||
return Task.CompletedTask;
|
||||
|
||||
var rep = new ReplacementBuilder()
|
||||
.WithOverride("%prefix%", () => _bss.Data.Prefix)
|
||||
.WithOverride("%bot.prefix%", () => _bss.Data.Prefix)
|
||||
.WithUser(msg.Author)
|
||||
.Build();
|
||||
|
||||
if (CREmbed.TryParse(settings.DmHelpText, out var embed))
|
||||
return msg.Channel.EmbedAsync(_rep.Replace(embed), _eb);
|
||||
|
||||
return msg.Channel.SendMessageAsync(_rep.Replace(settings.DmHelpText));
|
||||
var text = SmartText.CreateFrom(settings.DmHelpText);
|
||||
text = rep.Replace(text);
|
||||
|
||||
return msg.Channel.SendAsync(text);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace NadekoBot.Modules.Utility
|
||||
var text = SmartText.CreateFrom(quote.Text);
|
||||
text = rep.Replace(text);
|
||||
|
||||
await ctx.Channel.SendAsync(_eb, $"`#{quote.Id}` 📣 " + text, true);
|
||||
await ctx.Channel.SendAsync($"`#{quote.Id}` 📣 " + text, true);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
var text = SmartText.CreateFrom(quote.Text);
|
||||
text = rep.Replace(text);
|
||||
await ctx.Channel.SendAsync(_eb, infoText + text, true);
|
||||
await ctx.Channel.SendAsync(infoText + text, true);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
message = rep.Replace(message);
|
||||
|
||||
await channel.SendAsync(_eb, message, !((IGuildUser)Context.User).GuildPermissions.MentionEveryone);
|
||||
await channel.SendAsync(message, !((IGuildUser)Context.User).GuildPermissions.MentionEveryone);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
|
||||
Reference in New Issue
Block a user