Get rid of more D#+ references

This commit is contained in:
Ske
2021-01-15 11:29:43 +01:00
parent 04109a133f
commit da9d84a197
17 changed files with 63 additions and 71 deletions

View File

@@ -129,7 +129,7 @@ namespace PluralKit.Bot
}
if (!ctx.MessageContext.AllowAutoproxy)
eb.Field(new("\u200b", $"{Emojis.Note} Autoproxy is currently **disabled** for your account (<@{ctx.Author.Id}>). To enable it, use `pk;autoproxy account enable`."));
eb.Field(new("\u200b", $"{Emojis.Note} Autoproxy is currently **disabled** for your account (<@{ctx.AuthorNew.Id}>). To enable it, use `pk;autoproxy account enable`."));
return eb.Build();
}
@@ -191,7 +191,7 @@ namespace PluralKit.Bot
else
{
var statusString = ctx.MessageContext.AllowAutoproxy ? "enabled" : "disabled";
await ctx.Reply($"Autoproxy is currently **{statusString}** for account <@{ctx.Author.Id}>.");
await ctx.Reply($"Autoproxy is currently **{statusString}** for account <@{ctx.AuthorNew.Id}>.");
}
}
@@ -200,12 +200,12 @@ namespace PluralKit.Bot
var statusString = allow ? "enabled" : "disabled";
if (ctx.MessageContext.AllowAutoproxy == allow)
{
await ctx.Reply($"{Emojis.Note} Autoproxy is already {statusString} for account <@{ctx.Author.Id}>.");
await ctx.Reply($"{Emojis.Note} Autoproxy is already {statusString} for account <@{ctx.AuthorNew.Id}>.");
return;
}
var patch = new AccountPatch { AllowAutoproxy = allow };
await _db.Execute(conn => _repo.UpdateAccount(conn, ctx.Author.Id, patch));
await ctx.Reply($"{Emojis.Success} Autoproxy {statusString} for account <@{ctx.Author.Id}>.");
await _db.Execute(conn => _repo.UpdateAccount(conn, ctx.AuthorNew.Id, patch));
await ctx.Reply($"{Emojis.Success} Autoproxy {statusString} for account <@{ctx.AuthorNew.Id}>.");
}
private Task UpdateAutoproxy(Context ctx, AutoproxyMode autoproxyMode, MemberId? autoproxyMember)

View File

@@ -524,7 +524,7 @@ namespace PluralKit.Bot
{
// Try to resolve the user ID to find the associated account,
// so we can print their username.
var user = await ctx.Shard.GetUser(id);
var user = await ctx.RestNew.GetUser(id);
if (user != null)
return $"Account **{user.Username}#{user.Discriminator}** does not have a system registered.";
else

View File

@@ -20,7 +20,7 @@ namespace PluralKit.Bot
.Field(new("More information", "For a full list of commands, see [the command list](https://pluralkit.me/commands).\nFor a more in-depth explanation of message proxying, see [the documentation](https://pluralkit.me/guide#proxying).\nIf you're an existing user of Tupperbox, type `pk;import` and attach a Tupperbox export file (from `tul!export`) to import your data from there."))
.Field(new("Support server", "We also have a Discord server for support, discussion, suggestions, announcements, etc: https://discord.gg/PczBt78"))
.Footer(new($"By @Ske#6201 | Myriad by @Layl#8888 | GitHub: https://github.com/xSke/PluralKit/ | Website: https://pluralkit.me/"))
.Color((uint?) DiscordUtils.Blue.Value)
.Color(DiscordUtils.Blue)
.Build());
}

View File

@@ -6,6 +6,8 @@ using System.Text;
using System.Threading.Tasks;
using Myriad.Rest.Exceptions;
using Myriad.Rest.Types;
using Myriad.Rest.Types.Requests;
using Myriad.Types;
using Newtonsoft.Json;
@@ -32,7 +34,7 @@ namespace PluralKit.Bot
public async Task Import(Context ctx)
{
var url = ctx.RemainderOrNull() ?? ctx.Message.Attachments.FirstOrDefault()?.Url;
var url = ctx.RemainderOrNull() ?? ctx.MessageNew.Attachments.FirstOrDefault()?.Url;
if (url == null) throw Errors.NoImportFilePassed;
await ctx.BusyIndicator(async () =>
@@ -67,7 +69,7 @@ namespace PluralKit.Bot
if (!data.Valid)
throw Errors.InvalidImportFile;
if (data.LinkedAccounts != null && !data.LinkedAccounts.Contains(ctx.Author.Id))
if (data.LinkedAccounts != null && !data.LinkedAccounts.Contains(ctx.AuthorNew.Id))
{
var msg = $"{Emojis.Warn} You seem to importing a system profile belonging to another account. Are you sure you want to proceed?";
if (!await ctx.PromptYesNo(msg)) throw Errors.ImportCancelled;
@@ -75,7 +77,7 @@ namespace PluralKit.Bot
// If passed system is null, it'll create a new one
// (and that's okay!)
var result = await _dataFiles.ImportSystem(data, ctx.System, ctx.Author.Id);
var result = await _dataFiles.ImportSystem(data, ctx.System, ctx.AuthorNew.Id);
if (!result.Success)
await ctx.Reply($"{Emojis.Error} The provided system profile could not be imported. {result.Message}");
else if (ctx.System == null)
@@ -141,13 +143,16 @@ namespace PluralKit.Bot
try
{
var dm = await ctx.Rest.CreateDmAsync(ctx.AuthorNew.Id);
var dm = await ctx.RestNew.CreateDm(ctx.AuthorNew.Id);
// TODO: send file
var msg = await dm.SendFileAsync("system.json", stream, $"{Emojis.Success} Here you go!");
await dm.SendMessageAsync($"<{msg.Attachments[0].Url}>");
var msg = await ctx.RestNew.CreateMessage(dm.Id,
new MessageRequest {Content = $"{Emojis.Success} Here you go!"},
new[] {new MultipartFile("system.json", stream)});
await ctx.RestNew.CreateMessage(dm.Id, new MessageRequest { Content = $"<{msg.Attachments[0].Url}>" });
// If the original message wasn't posted in DMs, send a public reminder
if (ctx.ChannelNew.Type == Channel.ChannelType.Dm)
if (ctx.ChannelNew.Type != Channel.ChannelType.Dm)
await ctx.Reply($"{Emojis.Success} Check your DMs!");
}
catch (UnauthorizedException)

View File

@@ -5,8 +5,6 @@ using System.Web;
using Dapper;
using DSharpPlus.Entities;
using Myriad.Builders;
using Newtonsoft.Json.Linq;
@@ -92,7 +90,7 @@ namespace PluralKit.Bot
var scream = data["soulscream"]!.Value<string>();
var eb = new EmbedBuilder()
.Color((uint?) DiscordColor.Red.Value)
.Color(DiscordUtils.Red)
.Title(name)
.Url($"https://onomancer.sibr.dev/reflect?name={encoded}")
.Description($"*{scream}*");

View File

@@ -160,7 +160,7 @@ namespace PluralKit.Bot
else
await ctx.Reply(embed: new EmbedBuilder()
.Title("Member color")
.Color((uint?) target.Color.ToDiscordColor()!.Value.Value)
.Color(target.Color.ToDiscordColor())
.Thumbnail(new($"https://fakeimg.pl/256x256/{target.Color}/?text=%20"))
.Description($"This member's color is **#{target.Color}**."
+ (ctx.System?.Id == target.System ? $" To clear it, type `pk;member {target.Reference()} color -clear`." : ""))
@@ -178,7 +178,7 @@ namespace PluralKit.Bot
await ctx.Reply(embed: new EmbedBuilder()
.Title($"{Emojis.Success} Member color changed.")
.Color((uint?) color.ToDiscordColor()!.Value.Value)
.Color(color.ToDiscordColor())
.Thumbnail(new($"https://fakeimg.pl/256x256/{color}/?text=%20"))
.Build());
}

View File

@@ -6,8 +6,6 @@ using System.Threading.Tasks;
using App.Metrics;
using DSharpPlus;
using Humanizer;
using NodaTime;
@@ -22,8 +20,6 @@ using Myriad.Rest;
using Myriad.Rest.Types.Requests;
using Myriad.Types;
using Permissions = DSharpPlus.Permissions;
namespace PluralKit.Bot {
public class Misc
{
@@ -89,10 +85,10 @@ namespace PluralKit.Bot {
var totalMessages = _metrics.Snapshot.GetForContext("Application").Gauges.FirstOrDefault(m => m.MultidimensionalName == CoreMetrics.MessageCount.Name)?.Value ?? 0;
// TODO: shard stuff
var shardId = ctx.Shard.ShardId;
var shardTotal = ctx.Client.ShardClients.Count;
var shardId = ctx.ShardNew.ShardInfo?.ShardId ?? -1;
var shardTotal = ctx.Cluster.Shards.Count;
var shardUpTotal = _shards.Shards.Where(x => x.Connected).Count();
var shardInfo = _shards.GetShardInfo(ctx.Shard);
var shardInfo = _shards.GetShardInfo(ctx.ShardNew);
var process = Process.GetCurrentProcess();
var memoryUsage = process.WorkingSet64;
@@ -188,7 +184,7 @@ namespace PluralKit.Bot {
if (permissionsMissing.Count == 0)
{
eb.Description($"No errors found, all channels proxyable :)").Color((uint?) DiscordUtils.Green.Value);
eb.Description($"No errors found, all channels proxyable :)").Color(DiscordUtils.Green);
}
else
{
@@ -196,14 +192,13 @@ namespace PluralKit.Bot {
{
// Each missing permission field can have multiple missing channels
// so we extract them all and generate a comma-separated list
// TODO: port ToPermissionString?
var missingPermissionNames = ((Permissions)missingPermissionField).ToPermissionString();
var missingPermissionNames = ((PermissionSet) missingPermissionField).ToPermissionString();
var channelsList = string.Join("\n", channels
.OrderBy(c => c.Position)
.Select(c => $"#{c.Name}"));
eb.Field(new($"Missing *{missingPermissionNames}*", channelsList.Truncate(1000)));
eb.Color((uint?) DiscordUtils.Red.Value);
eb.Color(DiscordUtils.Red);
}
}

View File

@@ -34,7 +34,7 @@ namespace PluralKit.Bot
var system = _db.Execute(async c =>
{
var system = await _repo.CreateSystem(c, systemName);
await _repo.AddAccount(c, system.Id, ctx.Author.Id);
await _repo.AddAccount(c, system.Id, ctx.AuthorNew.Id);
return system;
});

View File

@@ -49,7 +49,7 @@ namespace PluralKit.Bot
ulong id;
if (!ctx.HasNext())
id = ctx.Author.Id;
id = ctx.AuthorNew.Id;
else if (!ctx.MatchUserRaw(out id))
throw new PKSyntaxError("You must pass an account to link with (either ID or @mention).");