mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-03 04:29:54 +03:00
Remora.Discord part 64 out of 63
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
abbb58f801
commit
c6eb0a44b9
10 changed files with 45 additions and 65 deletions
|
@ -42,15 +42,15 @@ public class KickCommandGroup : CommandGroup {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that kicks a Discord user with the specified reason.
|
||||
/// A slash command that kicks a Discord member with the specified reason.
|
||||
/// </summary>
|
||||
/// <param name="target">The user to kick.</param>
|
||||
/// <param name="target">The member to kick.</param>
|
||||
/// <param name="reason">
|
||||
/// The reason for this kick. Must be encoded with <see cref="Extensions.EncodeHeader" /> when passed to
|
||||
/// <see cref="IDiscordRestGuildAPI.RemoveGuildMemberAsync" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
||||
/// was kicked and vice-versa.
|
||||
/// </returns>
|
||||
[Command("kick", "кик")]
|
||||
|
@ -59,8 +59,8 @@ public class KickCommandGroup : CommandGroup {
|
|||
[RequireBotDiscordPermissions(DiscordPermission.KickMembers)]
|
||||
[Description("Kick member")]
|
||||
public async Task<Result> KickUserAsync(
|
||||
[Description("Member to kick")] IUser target,
|
||||
[Description("Kick reason")] string reason) {
|
||||
[Description("Member to kick")] IUser target,
|
||||
[Description("Kick reason")] string reason) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
|
|
|
@ -44,16 +44,16 @@ public class MuteCommandGroup : CommandGroup {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that mutes a Discord user with the specified reason.
|
||||
/// A slash command that mutes a Discord member with the specified reason.
|
||||
/// </summary>
|
||||
/// <param name="target">The user to mute.</param>
|
||||
/// <param name="duration">The duration for this mute. The user will be automatically unmuted after this duration.</param>
|
||||
/// <param name="target">The member to mute.</param>
|
||||
/// <param name="duration">The duration for this mute. The member will be automatically unmuted after this duration.</param>
|
||||
/// <param name="reason">
|
||||
/// The reason for this mute. Must be encoded with <see cref="Extensions.EncodeHeader" /> when passed to
|
||||
/// <see cref="IDiscordRestGuildAPI.ModifyGuildMemberAsync" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
||||
/// was muted and vice-versa.
|
||||
/// </returns>
|
||||
/// <seealso cref="UnmuteUserAsync" />
|
||||
|
@ -63,10 +63,9 @@ public class MuteCommandGroup : CommandGroup {
|
|||
[RequireBotDiscordPermissions(DiscordPermission.ModerateMembers)]
|
||||
[Description("Mute member")]
|
||||
public async Task<Result> MuteUserAsync(
|
||||
[Description("Member to mute")] IUser target,
|
||||
[Description("Mute reason")] string reason,
|
||||
[Description("Mute duration")]
|
||||
TimeSpan duration) {
|
||||
[Description("Member to mute")] IUser target,
|
||||
[Description("Mute reason")] string reason,
|
||||
[Description("Mute duration")] TimeSpan duration) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
|
@ -156,15 +155,15 @@ public class MuteCommandGroup : CommandGroup {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that unmutes a Discord user with the specified reason.
|
||||
/// A slash command that unmutes a Discord member with the specified reason.
|
||||
/// </summary>
|
||||
/// <param name="target">The user to unmute.</param>
|
||||
/// <param name="target">The member to unmute.</param>
|
||||
/// <param name="reason">
|
||||
/// The reason for this unmute. Must be encoded with <see cref="Extensions.EncodeHeader" /> when passed to
|
||||
/// <see cref="IDiscordRestGuildAPI.ModifyGuildMemberAsync" />.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
||||
/// was unmuted and vice-versa.
|
||||
/// </returns>
|
||||
/// <seealso cref="MuteUserAsync" />
|
||||
|
@ -175,10 +174,8 @@ public class MuteCommandGroup : CommandGroup {
|
|||
[RequireBotDiscordPermissions(DiscordPermission.ModerateMembers)]
|
||||
[Description("Unmute member")]
|
||||
public async Task<Result> UnmuteUserAsync(
|
||||
[Description("Member to unmute")]
|
||||
IUser target,
|
||||
[Description("Unmute reason")]
|
||||
string reason) {
|
||||
[Description("Member to unmute")] IUser target,
|
||||
[Description("Unmute reason")] string reason) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
|
|
|
@ -33,9 +33,18 @@ public class RemindCommandGroup : CommandGroup {
|
|||
_userApi = userApi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that schedules a reminder with the specified text.
|
||||
/// </summary>
|
||||
/// <param name="in">The period of time which must pass before the reminder will be sent.</param>
|
||||
/// <param name="message">The text of the reminder.</param>
|
||||
/// <returns>A feedback sending result which may or may not have succeeded.</returns>
|
||||
[Command("remind")]
|
||||
[Description("Create a reminder")]
|
||||
public async Task<Result> AddReminderAsync(TimeSpan duration, string text) {
|
||||
public async Task<Result> AddReminderAsync(
|
||||
[Description("After what period of time mention the reminder")]
|
||||
TimeSpan @in,
|
||||
[Description("Reminder message")] string message) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
|
@ -44,13 +53,13 @@ public class RemindCommandGroup : CommandGroup {
|
|||
if (!userResult.IsDefined(out var user))
|
||||
return Result.FromError(userResult);
|
||||
|
||||
var remindAt = DateTimeOffset.UtcNow.Add(duration);
|
||||
var remindAt = DateTimeOffset.UtcNow.Add(@in);
|
||||
|
||||
(await _dataService.GetMemberData(guildId.Value, userId.Value, CancellationToken)).Reminders.Add(
|
||||
new Reminder {
|
||||
RemindAt = remindAt,
|
||||
Channel = channelId.Value,
|
||||
Text = text
|
||||
Text = message
|
||||
});
|
||||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(string.Format(Messages.ReminderCreated, user.GetTag()), user)
|
||||
|
|
|
@ -5,11 +5,8 @@ using Boyfriend.Data;
|
|||
using Boyfriend.Services;
|
||||
using Remora.Commands.Attributes;
|
||||
using Remora.Commands.Groups;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.Commands.Attributes;
|
||||
using Remora.Discord.Commands.Contexts;
|
||||
using Remora.Discord.Commands.Feedback.Messages;
|
||||
using Remora.Discord.Commands.Feedback.Services;
|
||||
using Remora.Discord.Extensions.Embeds;
|
||||
using Remora.Discord.Extensions.Formatting;
|
||||
|
@ -44,9 +41,8 @@ public class SettingsCommandGroup : CommandGroup {
|
|||
/// <returns>
|
||||
/// A feedback sending result which may or may not have succeeded.
|
||||
/// </returns>
|
||||
[Command("settings list")]
|
||||
[Command("settingslist")]
|
||||
[Description("Shows settings list for this server")]
|
||||
[SuppressInteractionResponse(suppress: true)]
|
||||
public async Task<Result> SendSettingsListAsync() {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out _, out _))
|
||||
return Result.FromError(
|
||||
|
@ -77,21 +73,21 @@ public class SettingsCommandGroup : CommandGroup {
|
|||
.Build();
|
||||
if (!embed.IsDefined(out var built)) return Result.FromError(embed);
|
||||
|
||||
return (Result)await _feedbackService.SendContextualEmbedAsync(
|
||||
built, ct: CancellationToken, options: new FeedbackMessageOptions(MessageFlags: MessageFlags.Ephemeral));
|
||||
return (Result)await _feedbackService.SendContextualEmbedAsync(built, ct: CancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that modifies per-guild settings.
|
||||
/// A slash command that modifies per-guild settings.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A feedback sending result which may or may not have succeeded.
|
||||
/// </returns>
|
||||
/// <param name="setting">The setting to modify.</param>
|
||||
/// <param name="value">The new value of the setting.</param>
|
||||
/// <returns>A feedback sending result which may or may not have succeeded.</returns>
|
||||
[Command("settings")]
|
||||
[Description("Change settings for this server")]
|
||||
public async Task<Result> EditSettingsAsync(
|
||||
[Description("настройка")] string setting,
|
||||
[Description("значение")] string value) {
|
||||
[Description("The setting whose value you want to change")]
|
||||
string setting,
|
||||
[Description("Setting value")] string value) {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out _, out _))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
|
@ -144,8 +140,8 @@ public class SettingsCommandGroup : CommandGroup {
|
|||
var builder = new StringBuilder();
|
||||
|
||||
builder.Append(Markdown.InlineCode(setting))
|
||||
.Append($" {Messages.SettingIsNow} ")
|
||||
.Append(Markdown.InlineCode(value));
|
||||
.Append($" {Messages.SettingIsNow} ")
|
||||
.Append(Markdown.InlineCode(value));
|
||||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingSuccessfulyChanged, currentUser)
|
||||
.WithDescription(builder.ToString())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue