From c3ea830d7bc0830c64a8e94e75633cf72a5558d3 Mon Sep 17 00:00:00 2001 From: Toastie Date: Thu, 17 Oct 2024 16:50:12 +1300 Subject: [PATCH] added botonguild api endpoint --- src/EllieBot.GrpcApiBase/protos/other.proto | 10 +++++++++- src/EllieBot/Services/GrpcApi/OtherSvc.cs | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/EllieBot.GrpcApiBase/protos/other.proto b/src/EllieBot.GrpcApiBase/protos/other.proto index 9a5f9f8..1c82c8c 100644 --- a/src/EllieBot.GrpcApiBase/protos/other.proto +++ b/src/EllieBot.GrpcApiBase/protos/other.proto @@ -8,7 +8,7 @@ import "google/protobuf/timestamp.proto"; package other; service GrpcOther { - + rpc BotOnGuild(BotOnGuildRequest) returns (BotOnGuildReply); rpc GetGuilds(google.protobuf.Empty) returns (GetGuildsReply); rpc GetTextChannels(GetTextChannelsRequest) returns (GetTextChannelsReply); @@ -20,6 +20,14 @@ service GrpcOther { rpc GetServerInfo(ServerInfoRequest) returns (GetServerInfoReply); } +message BotOnGuildRequest { + uint64 guildId = 1; +} + +message BotOnGuildReply { + bool success = 1; +} + message GetGuildsReply { repeated GuildReply guilds = 1; } diff --git a/src/EllieBot/Services/GrpcApi/OtherSvc.cs b/src/EllieBot/Services/GrpcApi/OtherSvc.cs index 154acdc..482ce53 100644 --- a/src/EllieBot/Services/GrpcApi/OtherSvc.cs +++ b/src/EllieBot/Services/GrpcApi/OtherSvc.cs @@ -39,6 +39,19 @@ public sealed class OtherSvc : GrpcOther.GrpcOtherBase, IEService _cache = cache; } + [GrpcNoAuthRequired] + public override async Task BotOnGuild(BotOnGuildRequest request, ServerCallContext context) + { + var guild = await _client.GetGuildAsync(request.GuildId); + + var reply = new BotOnGuildReply + { + Success = guild is not null + }; + + return reply; + } + public override async Task GetTextChannels( GetTextChannelsRequest request, ServerCallContext context)