forked from darkalfx/requestrr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SlashCommands.txt
155 lines (141 loc) · 7.52 KB
/
SlashCommands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using System;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using Microsoft.Extensions.Logging;
using Requestrr.WebApi.Extensions;
using Requestrr.WebApi.RequestrrBot.ChatClients.Discord;
using Requestrr.WebApi.RequestrrBot.Movies;
using Requestrr.WebApi.RequestrrBot.TvShows;
using Requestrr.WebApi.RequestrrBot.Locale;
namespace Requestrr.WebApi.RequestrrBot
{
public class SlashCommands : ApplicationCommandModule
{
private readonly IServiceProvider _serviceProvider;
private readonly ILogger _logger;
public SlashCommands(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
_logger = _serviceProvider.Get<ILogger>();
}
[REQUEST_COMMAND_START]
[SlashCommandGroup("[REQUEST_GROUP_NAME]", "[REQUEST_GROUP_DESCRIPTION]")]
public class RequestGroup : ApplicationCommandModule
{
private readonly IServiceProvider _serviceProvider;
private readonly ILogger _logger;
public RequestGroup(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
_logger = _serviceProvider.Get<ILogger>();
}
[MOVIE_COMMAND_START]
[SlashCommand("[REQUEST_MOVIE_TITLE_NAME]", "[REQUEST_MOVIE_TITLE_DESCRIPTION]")]
[RequireRoles(new ulong[] { [REQUIRED_MOVIE_ROLE_IDS] })]
[RequireChannels(new ulong[] { [REQUIRED_CHANNEL_IDS] })]
public async Task MovieByTitle[MOVIE_CATEGORY_ID](InteractionContext ctx, [Option("[REQUEST_MOVIE_TITLE_OPTION_NAME]", "[REQUEST_MOVIE_TITLE_OPTION_DESCRIPTION]")] string movieTitle)
{
try
{
var settings = _serviceProvider.Get<DiscordSettingsProvider>().Provide();
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AsEphemeral(settings.AutomaticallyPurgeCommandMessages).WithContent(Language.Current.DiscordCommandSending));
var workFlow = _serviceProvider.Get<MovieWorkflowFactory>().CreateRequestingWorkflow(ctx.Interaction, [MOVIE_CATEGORY_ID]);
await workFlow.SearchMovieAsync(movieTitle.Trim());
}
catch (System.Exception ex)
{
_logger.LogError(ex, $"Error while searching movies with title {movieTitle} : " + ex.Message);
}
}
[TMDB_COMMAND_START]
[SlashCommand("[REQUEST_MOVIE_TMDB_NAME]", "[REQUEST_MOVIE_TMDB_DESCRIPTION]")]
[RequireRoles(new ulong[] { [REQUIRED_MOVIE_ROLE_IDS] })]
[RequireChannels(new ulong[] { [REQUIRED_CHANNEL_IDS] })]
public async Task ByTmdb[MOVIE_CATEGORY_ID](InteractionContext ctx, [Option("[REQUEST_MOVIE_TMDB_OPTION_NAME]", "[REQUEST_MOVIE_TMDB_OPTION_DESCRIPTION]")] long theMovieDbId)
{
try
{
var settings = _serviceProvider.Get<DiscordSettingsProvider>().Provide();
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AsEphemeral(settings.AutomaticallyPurgeCommandMessages).WithContent(Language.Current.DiscordCommandSending));
var workFlow = _serviceProvider.Get<MovieWorkflowFactory>().CreateRequestingWorkflow(ctx.Interaction, [MOVIE_CATEGORY_ID]);
await workFlow.SearchMovieAsync((int)theMovieDbId);
}
catch (System.Exception ex)
{
_logger.LogError(ex, $"Error while searching movies by TmDb Id {theMovieDbId} : " + ex.Message);
}
}
[TMDB_COMMAND_END]
[MOVIE_COMMAND_END]
[TV_COMMAND_START]
[SlashCommand("[REQUEST_TV_TITLE_NAME]", "[REQUEST_TV_TITLE_DESCRIPTION]")]
[RequireRoles(new ulong[] { [REQUIRED_TV_ROLE_IDS] })]
[RequireChannels(new ulong[] { [REQUIRED_CHANNEL_IDS] })]
public async Task TvByTitle[TV_CATEGORY_ID](InteractionContext ctx, [Option("[REQUEST_TV_TITLE_OPTION_NAME]", "[REQUEST_TV_TITLE_OPTION_DESCRIPTION]")] string tvShowTitle)
{
try
{
var settings = _serviceProvider.Get<DiscordSettingsProvider>().Provide();
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AsEphemeral(settings.AutomaticallyPurgeCommandMessages).WithContent(Language.Current.DiscordCommandSending));
var workFlow = _serviceProvider.Get<TvShowWorkflowFactory>().CreateRequestingWorkflow(ctx.Interaction, [TV_CATEGORY_ID]);
await workFlow.SearchTvShowAsync(tvShowTitle.Trim());
}
catch (System.Exception ex)
{
_logger.LogError(ex, $"Error while searching tv shows with title {tvShowTitle} : " + ex.Message);
}
}
[TVDB_COMMAND_START]
[SlashCommand("[REQUEST_TV_TVDB_NAME]", "[REQUEST_TV_TVDB_DESCRIPTION]")]
[RequireRoles(new ulong[] { [REQUIRED_TV_ROLE_IDS] })]
[RequireChannels(new ulong[] { [REQUIRED_CHANNEL_IDS] })]
public async Task ByTvdb[TV_CATEGORY_ID](InteractionContext ctx, [Option("[REQUEST_TV_TVDB_OPTION_NAME]", "[REQUEST_TV_TVDB_OPTION_DESCRIPTION]")] long tvDbID)
{
try
{
var settings = _serviceProvider.Get<DiscordSettingsProvider>().Provide();
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AsEphemeral(settings.AutomaticallyPurgeCommandMessages).WithContent(Language.Current.DiscordCommandSending));
var workFlow = _serviceProvider.Get<TvShowWorkflowFactory>().CreateRequestingWorkflow(ctx.Interaction, [TV_CATEGORY_ID]);
await workFlow.SearchTvShowAsync((int)tvDbID);
}
catch (System.Exception ex)
{
_logger.LogError(ex, $"Error while searching tv shows with tvdb id {tvDbID} : " + ex.Message);
}
}
[TVDB_COMMAND_END]
[TV_COMMAND_END]
}
[REQUEST_COMMAND_END]
[SlashCommand("[REQUEST_PING_NAME]", "[REQUEST_PING_DESCRIPTION]")]
[RequireChannels(new ulong[] { [REQUIRED_CHANNEL_IDS] })]
public async Task Ping(InteractionContext ctx)
{
try
{
await new DiscordPingWorkFlow(ctx).HandlePingAsync();
}
catch (System.Exception ex)
{
_logger.LogError(ex, "Error while sending ping command: " + ex.Message);
}
}
[SlashCommand("[REQUEST_HELP_NAME]", "[REQUEST_HELP_DESCRIPTION]")]
[RequireChannels(new ulong[] { [REQUIRED_CHANNEL_IDS] })]
public async Task Help(InteractionContext ctx)
{
try
{
await new DiscordHelpWorkFlow(_serviceProvider.Get<DiscordClient>(), ctx, _serviceProvider.Get<DiscordSettingsProvider>())
.HandleHelpAsync();
}
catch (System.Exception ex)
{
_logger.LogError(ex, "Error while sending help command: " + ex.Message);
}
}
}
}