mirror of
https://github.com/yawaflua/PL_JusticeBot.git
synced 2026-02-04 02:24:14 +02:00
add discord bot
change net6.0 net7.0
This commit is contained in:
27
Justice/Commands/Passports.cs
Normal file
27
Justice/Commands/Passports.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Discord;
|
||||
using Discord.Interactions;
|
||||
|
||||
namespace DiscordApp.Justice.Commands
|
||||
{
|
||||
public class Passports : InteractionModuleBase<SocketInteractionContext>
|
||||
{
|
||||
public InteractionService Commands { get; set; }
|
||||
[SlashCommand("send_passport_embed", description: "Отправляет сообщение для регистрации паспортов")]
|
||||
public async Task sendPassportBuilerEmbed()
|
||||
{
|
||||
await DeferAsync(true);
|
||||
var Embed = new EmbedBuilder()
|
||||
.WithTitle("**Регистрация паспорта!**")
|
||||
.WithDescription("Ниже вы можете нажать на кнопку для создания темплейта паспорта!")
|
||||
.WithColor(Color.Blue)
|
||||
.Build();
|
||||
var Components = new ComponentBuilder()
|
||||
.WithButton(new ButtonBuilder() { CustomId = "newPassport", Label = "Новый паспорт", Style = ButtonStyle.Primary })
|
||||
.WithButton(new ButtonBuilder() { CustomId = "reworkPassport", Label = "Замена паспорта", Style = ButtonStyle.Primary })
|
||||
.Build();
|
||||
await Context.Channel.SendMessageAsync(embed: Embed, components: Components);
|
||||
await FollowupAsync("OK!");//, ephemeral: true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
94
Justice/Commands/Settings.cs
Normal file
94
Justice/Commands/Settings.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Discord;
|
||||
using Discord.Interactions;
|
||||
using Discord.WebSocket;
|
||||
using DiscordApp.Database;
|
||||
using DiscordApp.Database.Tables;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
|
||||
namespace DiscordApp.Discord.Commands
|
||||
{
|
||||
public class AdminCommands : InteractionModuleBase<SocketInteractionContext>
|
||||
{
|
||||
public InteractionService Commands { get; set; }
|
||||
|
||||
[SlashCommand("branches", "Настройка автоветок")]
|
||||
[DefaultMemberPermissions(GuildPermission.Administrator)]
|
||||
public async Task addAutoBranches(IChannel channel, string branchName = "Обсуждение")
|
||||
{
|
||||
|
||||
await RespondAsync($"Автоветки для канала {channel.Name} настроены", ephemeral: true);
|
||||
Autobranches autobranches = new()
|
||||
{
|
||||
ChannelId = channel.Id,
|
||||
BranchName = branchName
|
||||
};
|
||||
Startup.appDbContext.Autobranches.Add(autobranches);
|
||||
}
|
||||
|
||||
[SlashCommand("emotes", "Настройка автоэмоций")]
|
||||
[DefaultMemberPermissions(GuildPermission.Administrator)]
|
||||
public async Task addAutoReact(string emote, IChannel channel)
|
||||
{
|
||||
var emotes = Emote.Parse(emote);
|
||||
await RespondAsync($"Автореакция {emotes.Url} для канала {channel.Name} настроены", ephemeral: true);
|
||||
|
||||
Autoreactions autoreactions = new()
|
||||
{
|
||||
ChannelId = channel.Id,
|
||||
EmoteId = emotes.ToString()
|
||||
};
|
||||
Startup.appDbContext.Autoreactions.Add(autoreactions);
|
||||
}
|
||||
|
||||
[SlashCommand("embed", "Отправить эмбед")]
|
||||
[DefaultMemberPermissions(GuildPermission.Administrator)]
|
||||
public async Task sendAsEmbed(string description, string? title = null, string? footer = null, IAttachment? attachment = null)
|
||||
{
|
||||
var author = new EmbedAuthorBuilder()
|
||||
.WithName(Context.User.GlobalName)
|
||||
.WithIconUrl(Context.User.GetAvatarUrl())
|
||||
.WithUrl("https://yaflay.ru/");
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
.WithTitle(title)
|
||||
.WithDescription(description)
|
||||
.WithFooter(footer)
|
||||
.WithColor(5793266)
|
||||
.WithAuthor(author)
|
||||
.WithImageUrl(attachment?.Url)
|
||||
.Build();
|
||||
|
||||
await DeferAsync(true);
|
||||
await FollowupAsync("Готово!", ephemeral: true);
|
||||
|
||||
await Context.Channel.SendMessageAsync(embed: embed);
|
||||
|
||||
}
|
||||
|
||||
[SlashCommand("verification", "Отправляет сообщение верификации")]
|
||||
[DefaultMemberPermissions(GuildPermission.Administrator)]
|
||||
public async Task sendVerificationEmbed()
|
||||
{
|
||||
await DeferAsync(true);
|
||||
var embed = new EmbedBuilder()
|
||||
.WithTitle("**Верификация игроков**")
|
||||
.WithDescription($"Если что-то случилось, и вам не выдается роль <@&1165687128366268511>, то нажмите на кнопку ниже!")
|
||||
.WithImageUrl("")
|
||||
.WithColor(Color.Blue)
|
||||
.Build();
|
||||
var components = new ComponentBuilder()
|
||||
.WithButton(
|
||||
new ButtonBuilder()
|
||||
.WithLabel("Верификация")
|
||||
.WithCustomId("UserVerification")
|
||||
.WithStyle(ButtonStyle.Success)
|
||||
)
|
||||
.Build();
|
||||
await Context.Channel.SendMessageAsync(embed: embed, components: components);
|
||||
await FollowupAsync("Ok", ephemeral: true);
|
||||
}
|
||||
|
||||
|
||||
// ReplyAsync is a method on ModuleBase
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user