Initial commit
This commit is contained in:
commit
4e795fddc7
37 changed files with 3269 additions and 0 deletions
42
Commands/AfkCommand.cs
Normal file
42
Commands/AfkCommand.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
public sealed class AfkCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Afk;
|
||||
|
||||
var reason = (string)arguments["reason"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForModerate(ctx))
|
||||
return;
|
||||
|
||||
if (reason.Length > 128)
|
||||
{
|
||||
this.SendSyntaxError();
|
||||
return;
|
||||
}
|
||||
|
||||
SocialPlugin.Plugin.Users![ctx.User.Id].AfkStatus.Reason = reason.FullSanitize();
|
||||
SocialPlugin.Plugin.Users![ctx.User.Id].AfkStatus.TimeStamp = DateTime.UtcNow;
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = $"{ctx.User.Mention} {this.GetString(CommandKey.SetAfk, true)}"
|
||||
}.AsSuccess(ctx, this.GetString(CommandKey.Title)));
|
||||
await Task.Delay(10000);
|
||||
_ = ctx.ResponseMessage.DeleteAsync();
|
||||
});
|
||||
}
|
||||
}
|
||||
39
Commands/BlockUserCommand.cs
Normal file
39
Commands/BlockUserCommand.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class BlockUserCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.BlockUser;
|
||||
|
||||
var victim = (DiscordUser)arguments["victim"];
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(victim.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(CommandKey.AlreadyBlocked, true)).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (victim.Id == ctx.Client.CurrentUser.Id || victim.Id == ctx.User.Id || victim.IsBot || (victim.Flags?.HasFlag(UserFlags.Staff) ?? false))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(CommandKey.CannotBlock, true)).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers = SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Add(victim.Id);
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(CommandKey.Blocked, true, new TVar("User", victim.Mention))).AsSuccess(ctx));
|
||||
});
|
||||
}
|
||||
}
|
||||
67
Commands/BoopCommand.cs
Normal file
67
Commands/BoopCommand.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class BoopCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Boop;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.Member.DisplayName)),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "boop");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
68
Commands/CuddleCommand.cs
Normal file
68
Commands/CuddleCommand.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class CuddleCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Cuddle;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.Member.DisplayName)),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "cuddle");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false),
|
||||
new TVar("Emoji", SocialPlugin.Plugin.LoadedConfig.Cuddle, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
68
Commands/HighFiveCommand.cs
Normal file
68
Commands/HighFiveCommand.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class HighFiveCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.HighFive;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.Member.DisplayName)),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "highfive");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false),
|
||||
new TVar("Emoji", SocialPlugin.Plugin.LoadedConfig.Proud, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
72
Commands/HugCommand.cs
Normal file
72
Commands/HugCommand.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class HugCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Hug;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
string[] PositiveEmojis = { "♥", SocialPlugin.Plugin.LoadedConfig.Hug };
|
||||
string[] NegativeEmojis = { "😢", "😓" };
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.Member.DisplayName),
|
||||
new TVar("Emoji", NegativeEmojis.SelectRandom())),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "hug");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false),
|
||||
new TVar("Emoji", PositiveEmojis.SelectRandom(), false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
67
Commands/KillCommand.cs
Normal file
67
Commands/KillCommand.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class KillCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Kill;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(new TVar("User1", ctx.Member.DisplayName)),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "kill");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false),
|
||||
new TVar("Emoji", SocialPlugin.Plugin.LoadedConfig.Slap, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
67
Commands/KissCommand.cs
Normal file
67
Commands/KissCommand.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class KissCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Kiss;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(new TVar("User1", ctx.Member.DisplayName)),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "kiss");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false),
|
||||
new TVar("Emoji", SocialPlugin.Plugin.LoadedConfig.Cuddle, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
68
Commands/PatCommand.cs
Normal file
68
Commands/PatCommand.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class PatCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Pat;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.Member.DisplayName),
|
||||
new TVar("Emoji", "😢")),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "pat");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
67
Commands/SlapCommand.cs
Normal file
67
Commands/SlapCommand.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class SlapCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.Slap;
|
||||
var ModuleKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands;
|
||||
|
||||
var user = (DiscordUser)arguments["user"];
|
||||
|
||||
if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
|
||||
return;
|
||||
|
||||
if (SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(user.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SocialPlugin.Plugin.Users![user.Id].BlockedUsers.Contains(ctx.User.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(ModuleKey.BlockedByVictim, true, new TVar("User", user.Mention))).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
var phrases = CommandKey.Other.Get(ctx.DbGuild);
|
||||
var self_phrases = CommandKey.Self.Get(ctx.DbGuild);
|
||||
|
||||
if (ctx.Member.Id == user.Id)
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Title = self_phrases.SelectRandom().Build(new TVar("User1", ctx.Member.DisplayName)),
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await SocialCommandAbstractions.GetGif(ctx.Bot, "slap");
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
|
||||
{
|
||||
Description = phrases.SelectRandom().Build(
|
||||
new TVar("User1", ctx.User.Mention, false),
|
||||
new TVar("User2", user.Mention, false),
|
||||
new TVar("Emoji", SocialPlugin.Plugin.LoadedConfig.Slap, false))
|
||||
.Bold(),
|
||||
ImageUrl = response.Item2,
|
||||
Color = EmbedColors.HiddenSidebar,
|
||||
Footer = ctx.GenerateUsedByFooter(response.Item1),
|
||||
}).WithAllowedMention(UserMention.All));
|
||||
});
|
||||
}
|
||||
}
|
||||
49
Commands/SocialCommandAbstractions.cs
Normal file
49
Commands/SocialCommandAbstractions.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
internal static class SocialCommandAbstractions
|
||||
{
|
||||
private static HttpClient? httpClient = null;
|
||||
internal static readonly string[] sourceArray = new string[] { "cuddle", "slap", "pat", "hug", "kiss" };
|
||||
|
||||
internal static async Task<Tuple<string, string>> GetGif(Bot bot, string action)
|
||||
{
|
||||
if (httpClient is null)
|
||||
{
|
||||
httpClient = new(new SocketsHttpHandler() { PooledConnectionLifetime = TimeSpan.FromMinutes(1) });
|
||||
httpClient.Timeout = TimeSpan.FromSeconds(2);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var request = JsonConvert.DeserializeObject<KawaiiResponse>(await httpClient.GetStringAsync($"https://kawaii.red/api/gif/{action}" +
|
||||
$"/token={SocialPlugin.Plugin!.LoadedConfig.KawaiiRedToken}/"));
|
||||
return new Tuple<string, string>("kawaii.red", request!.response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SocialPlugin.Plugin!._logger.LogWarn("Failed to fetch gif from kawaii.red", ex);
|
||||
|
||||
try
|
||||
{
|
||||
if (!sourceArray.Contains(action))
|
||||
throw new NotSupportedException("Unsupported gif type");
|
||||
|
||||
var request = JsonConvert.DeserializeObject<NekosLifeRequest>(await httpClient.GetStringAsync($"https://nekos.life/api/v2/img/{action}"));
|
||||
return new Tuple<string, string>("nekos.life", request!.url);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
SocialPlugin.Plugin!._logger.LogError("Failed to fetch gif from kawaii.red & nekos.life", ex1);
|
||||
return new Tuple<string, string>("GIF Service currently unavailable", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Commands/UnblockUserCommand.cs
Normal file
33
Commands/UnblockUserCommand.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Project Makoto
|
||||
// Copyright (C) 2023 Fortunevale
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY
|
||||
|
||||
namespace ProjectMakoto.Commands;
|
||||
|
||||
internal sealed class UnblockUserCommand : BaseCommand
|
||||
{
|
||||
public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary<string, object> arguments)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var CommandKey = ((Plugins.Social.Entities.Translations)SocialPlugin.Plugin!.Translations).Commands.UnblockUser;
|
||||
|
||||
var victim = (DiscordUser)arguments["victim"];
|
||||
|
||||
if (!SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Contains(victim.Id))
|
||||
{
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(CommandKey.NotBlocked, true)).AsError(ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers = SocialPlugin.Plugin.Users![ctx.User.Id].BlockedUsers.Remove(x => x.ToString(), victim.Id);
|
||||
|
||||
_ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(CommandKey.Unblocked, true, new TVar("User", victim.Mention))).AsSuccess(ctx));
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue