Replaced access to .Context with .ctx

This commit is contained in:
Kwoth
2021-07-14 21:51:15 +02:00
parent 3c33c55dda
commit 42d623b696
19 changed files with 77 additions and 77 deletions

View File

@@ -32,12 +32,12 @@ namespace NadekoBot.Modules.Administration
return;
await ((ITextChannel) Context.Channel).ModifyAsync(tcp =>
await ((ITextChannel) ctx.Channel).ModifyAsync(tcp =>
{
tcp.SlowModeInterval = seconds;
});
await Context.OkAsync();
await ctx.OkAsync();
}
[NadekoCommand, Aliases]

View File

@@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Administration
}
var aggregatePerms = perms.Aggregate((acc, seed) => seed | acc);
await _service.AddOverride(Context.Guild.Id, cmd.Name, aggregatePerms);
await _service.AddOverride(ctx.Guild.Id, cmd.Name, aggregatePerms);
await ReplyConfirmLocalizedAsync("perm_override",
Format.Bold(aggregatePerms.ToString()),
@@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Administration
if (!result)
return;
await _service.ClearAllOverrides(Context.Guild.Id);
await _service.ClearAllOverrides(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync("perm_override_all");
}
@@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Administration
if (--page < 0)
return;
var overrides = await _service.GetAllOverrides(Context.Guild.Id);
var overrides = await _service.GetAllOverrides(ctx.Guild.Id);
await ctx.SendPaginatedConfirmAsync(page, curPage =>
{

View File

@@ -43,8 +43,8 @@ namespace NadekoBot.Modules.Administration
return;
}
if (Context.User.Id != Context.Guild.OwnerId &&
role.Position >= ((SocketGuildUser) Context.User).Roles.Max(x => x.Position))
if (ctx.User.Id != ctx.Guild.OwnerId &&
role.Position >= ((SocketGuildUser) ctx.User).Roles.Max(x => x.Position))
{
await ReplyErrorLocalizedAsync("insuf_perms_u").ConfigureAwait(false);
return;

View File

@@ -385,7 +385,7 @@ namespace NadekoBot.Modules.Administration
[Priority(1)]
public async Task SetNick(IGuildUser gu, [Leftover] string newNick = null)
{
var sg = (SocketGuild) Context.Guild;
var sg = (SocketGuild) ctx.Guild;
if (sg.OwnerId == gu.Id ||
gu.GetRoles().Max(r => r.Position) >= sg.CurrentUser.GetRoles().Max(r => r.Position))
{

View File

@@ -168,10 +168,10 @@ namespace NadekoBot.Modules.Administration
[Ratelimit(5)]
public async Task ByeTest([Leftover] IGuildUser user = null)
{
user = user ?? (IGuildUser) Context.User;
user = user ?? (IGuildUser) ctx.User;
await _service.ByeTest((ITextChannel)Context.Channel, user);
var enabled = _service.GetByeEnabled(Context.Guild.Id);
await _service.ByeTest((ITextChannel)ctx.Channel, user);
var enabled = _service.GetByeEnabled(ctx.Guild.Id);
if (!enabled)
{
await ReplyConfirmLocalizedAsync("byemsg_enable", $"`{Prefix}bye`").ConfigureAwait(false);
@@ -184,10 +184,10 @@ namespace NadekoBot.Modules.Administration
[Ratelimit(5)]
public async Task GreetTest([Leftover] IGuildUser user = null)
{
user = user ?? (IGuildUser) Context.User;
user = user ?? (IGuildUser) ctx.User;
await _service.GreetTest((ITextChannel)Context.Channel, user);
var enabled = _service.GetGreetEnabled(Context.Guild.Id);
await _service.GreetTest((ITextChannel)ctx.Channel, user);
var enabled = _service.GetGreetEnabled(ctx.Guild.Id);
if (!enabled)
{
await ReplyConfirmLocalizedAsync("greetmsg_enable", $"`{Prefix}greet`").ConfigureAwait(false);
@@ -200,15 +200,15 @@ namespace NadekoBot.Modules.Administration
[Ratelimit(5)]
public async Task GreetDmTest([Leftover] IGuildUser user = null)
{
user = user ?? (IGuildUser) Context.User;
user = user ?? (IGuildUser) ctx.User;
var channel = await user.GetOrCreateDMChannelAsync();
var success = await _service.GreetDmTest(channel, user);
if (success)
await Context.OkAsync();
await ctx.OkAsync();
else
await Context.WarningAsync();
var enabled = _service.GetGreetDmEnabled(Context.Guild.Id);
await ctx.WarningAsync();
var enabled = _service.GetGreetDmEnabled(ctx.Guild.Id);
if (!enabled)
await ReplyConfirmLocalizedAsync("greetdmmsg_enable", $"`{Prefix}greetdm`").ConfigureAwait(false);
}

View File

@@ -33,14 +33,14 @@ namespace NadekoBot.Modules.Administration
private async Task<bool> CheckRoleHierarchy(IGuildUser target)
{
var curUser = ((SocketGuild) ctx.Guild).CurrentUser;
var ownerId = Context.Guild.OwnerId;
var ownerId = ctx.Guild.OwnerId;
var modMaxRole = ((IGuildUser) ctx.User).GetRoles().Max(r => r.Position);
var targetMaxRole = target.GetRoles().Max(r => r.Position);
var botMaxRole = curUser.GetRoles().Max(r => r.Position);
// bot can't punish a user who is higher in the hierarchy. Discord will return 403
// moderator can be owner, in which case role hierarchy doesn't matter
// otherwise, moderator has to have a higher role
if ((botMaxRole <= targetMaxRole || (Context.User.Id != ownerId && targetMaxRole >= modMaxRole)) || target.Id == ownerId)
if ((botMaxRole <= targetMaxRole || (ctx.User.Id != ownerId && targetMaxRole >= modMaxRole)) || target.Id == ownerId)
{
await ReplyErrorLocalizedAsync("hierarchy");
return false;
@@ -150,7 +150,7 @@ namespace NadekoBot.Modules.Administration
var opts = OptionsParser.ParseFrom<WarnExpireOptions>(args);
await Context.Channel.TriggerTypingAsync().ConfigureAwait(false);
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
await _service.WarnExpireAsync(ctx.Guild.Id, days, opts.Delete).ConfigureAwait(false);
if(days == 0)
@@ -425,7 +425,7 @@ namespace NadekoBot.Modules.Administration
if (time.Time > TimeSpan.FromDays(49))
return;
var guildUser = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(Context.Guild.Id, user.Id);
var guildUser = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, user.Id);
if (guildUser != null && !await CheckRoleHierarchy(guildUser))
return;
@@ -450,7 +450,7 @@ namespace NadekoBot.Modules.Administration
}
}
await _mute.TimedBan(Context.Guild, user, time.Time, ctx.User.ToString() + " | " + msg).ConfigureAwait(false);
await _mute.TimedBan(ctx.Guild, user, time.Time, ctx.User.ToString() + " | " + msg).ConfigureAwait(false);
var toSend = _eb.Create().WithOkColor()
.WithTitle("⛔️ " + GetText("banned_user"))
.AddField(GetText("username"), user.ToString(), true)
@@ -473,7 +473,7 @@ namespace NadekoBot.Modules.Administration
[Priority(0)]
public async Task Ban(ulong userId, [Leftover] string msg = null)
{
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(Context.Guild.Id, userId);
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (user is null)
{
await ctx.Guild.AddBanAsync(userId, 7, ctx.User.ToString() + " | " + msg);
@@ -540,7 +540,7 @@ namespace NadekoBot.Modules.Administration
{
if (message is null)
{
var template = _service.GetBanTemplate(Context.Guild.Id);
var template = _service.GetBanTemplate(ctx.Guild.Id);
if (template is null)
{
await ReplyConfirmLocalizedAsync("banmsg_default");
@@ -551,7 +551,7 @@ namespace NadekoBot.Modules.Administration
return;
}
_service.SetBanTemplate(Context.Guild.Id, message);
_service.SetBanTemplate(ctx.Guild.Id, message);
await ctx.OkAsync();
}
@@ -561,7 +561,7 @@ namespace NadekoBot.Modules.Administration
[BotPerm(GuildPerm.BanMembers)]
public async Task BanMsgReset()
{
_service.SetBanTemplate(Context.Guild.Id, null);
_service.SetBanTemplate(ctx.Guild.Id, null);
await ctx.OkAsync();
}
@@ -586,7 +586,7 @@ namespace NadekoBot.Modules.Administration
var dmChannel = await ctx.User.GetOrCreateDMChannelAsync();
var defaultMessage = GetText("bandm", Format.Bold(ctx.Guild.Name), reason);
var embed = _service.GetBanUserDmEmbed(Context,
(IGuildUser)Context.User,
(IGuildUser)ctx.User,
defaultMessage,
reason,
duration);
@@ -607,7 +607,7 @@ namespace NadekoBot.Modules.Administration
return;
}
await Context.OkAsync();
await ctx.OkAsync();
}
}
@@ -669,7 +669,7 @@ namespace NadekoBot.Modules.Administration
[BotPerm(GuildPerm.BanMembers)]
public async Task Softban(ulong userId, [Leftover] string msg = null)
{
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(Context.Guild.Id, userId);
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (user is null)
return;
@@ -725,7 +725,7 @@ namespace NadekoBot.Modules.Administration
[Priority(0)]
public async Task Kick(ulong userId, [Leftover] string msg = null)
{
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(Context.Guild.Id, userId);
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (user is null)
return;