Skip to content

Commit

Permalink
add message count req and add back required roles.
Browse files Browse the repository at this point in the history
  • Loading branch information
SylveonDeko committed Oct 22, 2024
1 parent 6942c4d commit b6734cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Mewdeko/Common/NewEmbed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private static SelectMenuBuilder GetSelectMenu(NewEmbedComponent sel, int pos, u
sb = error.WithPlaceholder("displayName.length cannot be greater than 80");
else if (sel.Options.Any(x => x.Name.Length > 100))
sb = error.WithPlaceholder("select option names length cannot be greater than 100");
else if (sel.Options.Any(x => x.Description.Length > 100))
else if (sel.Options.Any(x => x.Description?.Length > 100))
sb = error.WithPlaceholder("select option description length cannot be greater than 100");
else
sb
Expand All @@ -341,7 +341,7 @@ private static SelectMenuBuilder GetSelectMenu(NewEmbedComponent sel, int pos, u
.WithMinValues(sel.MinOptions)
.WithOptions(sel.Options
.Select(x =>
new SelectMenuOptionBuilder(x.Name, x.Id.ToString(), x.Description, x.Emoji?.ToIEmote()))
new SelectMenuOptionBuilder(x.Name, x.Id.ToString(), x.Description ?? "None", x.Emoji?.ToIEmote()))
.ToList());

return sb;
Expand Down Expand Up @@ -481,11 +481,11 @@ public class NewEmbedSelectOption
/// <summary>
/// Gets or sets the emoji of the option.
/// </summary>
public string Emoji { get; set; }
public string? Emoji { get; set; }

/// <summary>
/// Gets or sets the description of the option.
/// </summary>
public string Description { get; set; }
public string? Description { get; set; }
}
}
11 changes: 9 additions & 2 deletions src/Mewdeko/Modules/Giveaways/SlashGiveaways.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ await ctx.Channel.SendErrorAsync("There have been no giveaways here, so no stats
[SlashUserPerm(GuildPermission.ManageMessages)]
[CheckPermissions]
public async Task GStart(ITextChannel chan, TimeSpan time, int winners, string what, IRole pingRole = null,
IAttachment attachment = null, IUser host = null, bool useButton = false, bool useCaptcha = false)
IAttachment attachment = null, IUser host = null, bool useButton = false, bool useCaptcha = false,
IRole[] requiredRoles = null, ulong requiredMessages = 0)
{
host ??= ctx.User;
await ctx.Interaction.DeferAsync().ConfigureAwait(false);
Expand All @@ -272,6 +273,12 @@ public async Task GStart(ITextChannel chan, TimeSpan time, int winners, string w
return;
}

string reqs;
if (requiredRoles is null || requiredRoles.Length == 0)
reqs = "";
else
reqs = string.Join("\n", requiredRoles.Select(x => x.Id));

var emote = (await Service.GetGiveawayEmote(ctx.Guild.Id)).ToIEmote();
if (!useButton && !useCaptcha)
{
Expand Down Expand Up @@ -312,7 +319,7 @@ await ctx.Interaction.SendErrorFollowupAsync("I'm unable to use external emotes!

await Service.GiveawaysInternal(chan, time, what, winners, host.Id, ctx.Guild.Id,
ctx.Channel as ITextChannel, ctx.Guild, banner: attachment?.Url, pingROle: pingRole, useButton: useButton,
useCaptcha: useCaptcha).ConfigureAwait(false);
useCaptcha: useCaptcha, reqroles: reqs, messageCount: requiredMessages).ConfigureAwait(false);
}

/// <summary>
Expand Down

0 comments on commit b6734cc

Please sign in to comment.