mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-12-12 13:16:44 +00:00
Merge pull request #186 from 13xforever/vnext
I swear this is the last one [for today]
This commit is contained in:
commit
f131c14ade
@ -24,11 +24,12 @@ namespace CompatBot.Commands
|
||||
[GroupCommand]
|
||||
public async Task ShowExplanation(CommandContext ctx, [RemainingText, Description("Term to explain")] string term)
|
||||
{
|
||||
string inSpecificLocation = null;
|
||||
if (!LimitedToSpamChannel.IsSpamChannel(ctx.Channel))
|
||||
if (string.IsNullOrEmpty(term))
|
||||
{
|
||||
var spamChannel = await ctx.Client.GetChannelAsync(Config.BotSpamId).ConfigureAwait(false);
|
||||
inSpecificLocation = $" in {spamChannel.Mention} or bot DMs";
|
||||
var ch = LimitedToSpamChannel.IsSpamChannel(ctx.Channel) ? ctx.Channel : await ctx.Member.CreateDmChannelAsync().ConfigureAwait(false);
|
||||
await ch.SendMessageAsync("Please specify term to explain").ConfigureAwait(false);
|
||||
await List(ctx).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await DiscordInviteFilter.CheckMessageForInvitesAsync(ctx.Client, ctx.Message).ConfigureAwait(false))
|
||||
@ -37,12 +38,6 @@ namespace CompatBot.Commands
|
||||
if (!await AntipiracyMonitor.IsClean(ctx.Client, ctx.Message).ConfigureAwait(false))
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(term))
|
||||
{
|
||||
await ctx.RespondAsync($"You may want to look at available terms by using `{Config.CommandPrefix}explain list`{inSpecificLocation}").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
term = term.ToLowerInvariant();
|
||||
using (var db = new BotDb())
|
||||
{
|
||||
@ -81,6 +76,12 @@ namespace CompatBot.Commands
|
||||
}
|
||||
}
|
||||
|
||||
string inSpecificLocation = null;
|
||||
if (!LimitedToSpamChannel.IsSpamChannel(ctx.Channel))
|
||||
{
|
||||
var spamChannel = await ctx.Client.GetChannelAsync(Config.BotSpamId).ConfigureAwait(false);
|
||||
inSpecificLocation = $" in {spamChannel.Mention} or bot DMs";
|
||||
}
|
||||
var msg = $"Unknown term `{term.Sanitize()}`. Use `{Config.CommandPrefix}explain list` to look at defined terms{inSpecificLocation}";
|
||||
await ctx.RespondAsync(msg).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ namespace CompatBot.Commands
|
||||
|
||||
[Command("rate"), Cooldown(20, 60, CooldownBucketType.Channel)]
|
||||
[Description("Gives a ~~random~~ expert judgment on the matter at hand")]
|
||||
public async Task Rate(CommandContext ctx, [RemainingText, Description("Something to rate")] string whatever)
|
||||
public async Task Rate(CommandContext ctx, [RemainingText, Description("Something to rate")] string whatever = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -247,6 +247,28 @@ namespace CompatBot.Commands
|
||||
suffix = "'s" + suffix;
|
||||
word = word.Substring(0, word.Length - 2);
|
||||
}
|
||||
|
||||
void MakeCustomRoleRating(DiscordMember m)
|
||||
{
|
||||
if (m != null && !choiceFlags.Contains('f'))
|
||||
{
|
||||
var roleList = m.Roles.ToList();
|
||||
if (roleList.Any())
|
||||
{
|
||||
|
||||
var role = roleList[new Random((prefix + m.Id).GetHashCode()).Next(roleList.Count)].Name?.ToLowerInvariant();
|
||||
if (!string.IsNullOrEmpty(role))
|
||||
{
|
||||
if (role.EndsWith('s'))
|
||||
role = role.Substring(0, role.Length - 1);
|
||||
var article = Vowels.Contains(role[0]) ? "n" : "";
|
||||
choices = RateAnswers.Concat(Enumerable.Repeat($"Pretty fly for a{article} {role} guy", RateAnswers.Count / 20)).ToList();
|
||||
choiceFlags.Add('f');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Me.Contains(word))
|
||||
result.Append(ctx.Message.Author.Mention);
|
||||
else if (word == "my")
|
||||
@ -257,27 +279,12 @@ namespace CompatBot.Commands
|
||||
result.Append(ctx.Client.CurrentUser.Mention).Append("'s");
|
||||
else if (word.StartsWith("actually") || word.StartsWith("nevermind") || word.StartsWith("nvm"))
|
||||
result.Clear();
|
||||
else if (i == 0 && await new DiscordUserConverter().ConvertAsync(word, ctx).ConfigureAwait(false) is Optional<DiscordUser> user && user.HasValue)
|
||||
else if (i == 0 && await new DiscordMemberConverter().ConvertAsync(word, ctx).ConfigureAwait(false) is Optional<DiscordMember> member && member.HasValue)
|
||||
{
|
||||
var u = user.Value;
|
||||
result.Append(u.Mention);
|
||||
var roles = ctx.Client.GetMember(u)?.Roles.ToList();
|
||||
if (roles?.Count > 0)
|
||||
{
|
||||
var m = member.Value;
|
||||
MakeCustomRoleRating(m);
|
||||
result.Append(m.Mention);
|
||||
|
||||
var role = roles[new Random((prefix + u.Id).GetHashCode()).Next(roles.Count)].Name?.ToLowerInvariant();
|
||||
if (!string.IsNullOrEmpty(role))
|
||||
{
|
||||
if (role.EndsWith('s'))
|
||||
role = role.Substring(0, role.Length - 1);
|
||||
var article = Vowels.Contains(role[0]) ? "n" : "";
|
||||
if (!choiceFlags.Contains('f'))
|
||||
{
|
||||
choices = RateAnswers.Concat(Enumerable.Repeat($"Pretty fly for a{article} {role} guy", RateAnswers.Count / 20)).ToList();
|
||||
choiceFlags.Add('f');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nekoMatch.Contains(word))
|
||||
{
|
||||
@ -286,6 +293,7 @@ namespace CompatBot.Commands
|
||||
choices = RateAnswers.Concat(Enumerable.Repeat("Ugh", RateAnswers.Count * 3)).ToList();
|
||||
choiceFlags.Add('n');
|
||||
}
|
||||
MakeCustomRoleRating(nekoMember);
|
||||
result.Append(nekoUser.Mention);
|
||||
}
|
||||
else if (kdMatch.Contains(word))
|
||||
@ -295,6 +303,7 @@ namespace CompatBot.Commands
|
||||
choices = RateAnswers.Concat(Enumerable.Repeat("RSX genius", RateAnswers.Count * 3)).ToList();
|
||||
choiceFlags.Add('k');
|
||||
}
|
||||
MakeCustomRoleRating(kdMember);
|
||||
result.Append(kdUser.Mention);
|
||||
}
|
||||
else
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CompatBot.Commands.Attributes;
|
||||
using CompatBot.Database.Providers;
|
||||
using CompatBot.Utils;
|
||||
using DSharpPlus.CommandsNext;
|
||||
@ -23,7 +22,7 @@ namespace CompatBot.Commands
|
||||
{
|
||||
await ctx.ReactWithAsync(Config.Reactions.Success,
|
||||
$"{user.Mention} was successfully added as moderator!\n" +
|
||||
"Try using `!help` to see new commands available to you"
|
||||
$"Try using `{Config.CommandPrefix}help` to see new commands available to you"
|
||||
).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
|
@ -69,7 +69,7 @@ namespace CompatBot.EventHandlers
|
||||
var info = status.Results.First().Value;
|
||||
var botSpamChannel = await args.Client.GetChannelAsync(Config.BotSpamId).ConfigureAwait(false);
|
||||
var msg = $"{args.Author.Mention} {info.Title} is {info.Status.ToLowerInvariant()} since {info.ToUpdated()}\n" +
|
||||
$"for more results please use compatibility list (<https://rpcs3.net/compatibility>) or `!c` command in {botSpamChannel.Mention} (`!c {gameTitle.Sanitize()}`)";
|
||||
$"for more results please use compatibility list (<https://rpcs3.net/compatibility>) or `{Config.CommandPrefix}c` command in {botSpamChannel.Mention} (`!c {gameTitle.Sanitize()}`)";
|
||||
await args.Channel.SendMessageAsync(msg).ConfigureAwait(false);
|
||||
CooldownBuckets[args.Channel.Id] = DateTime.UtcNow;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user