Skip to content

Commit

Permalink
Merge pull request #238 from fmbot-discord/feature/discord-skus
Browse files Browse the repository at this point in the history
Feature/discord skus
  • Loading branch information
th0mk committed Jun 21, 2023
2 parents 4758d4a + 4f09b8b commit 5929567
Show file tree
Hide file tree
Showing 29 changed files with 572 additions and 46 deletions.
3 changes: 1 addition & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ COPY ["src/FMBot.Persistence.EntityFrameWork", "FMBot.Persistence.EntityFrameWor
COPY ["src/FMBot.Youtube", "FMBot.Youtube/"]
COPY ["src/FMBot.LastFM", "FMBot.LastFM/"]
COPY ["src/FMBot.LastFM.Domain", "FMBot.LastFM.Domain/"]
COPY ["src/FMBot.Logger", "FMBot.Logger/"]
COPY ["src/FMBot.OpenCollective", "FMBot.OpenCollective/"]
COPY ["src/FMBot.Subscriptions", "FMBot.Subscriptions/"]
COPY ["src/FMBot.Discogs", "FMBot.Discogs/"]
RUN dotnet restore "FMBot.Bot/FMBot.Bot.csproj"
COPY . .
Expand Down
9 changes: 9 additions & 0 deletions src/FMBot.Bot/Builders/ChartBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ public ChartBuilders(ChartService chartService, LastFmRepository lastFmRepositor
if (supporter != null)
{
response.Components = new ComponentBuilder().WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterOverviewLink);

if (PublicProperties.DiscordPurchaseLink != null)
{
response.Components.WithButton(Constants.GetDiscordSupporterButton, style: ButtonStyle.Link, url: PublicProperties.DiscordPurchaseLink);
}
}

var nsfwAllowed = context.DiscordGuild == null || ((SocketTextChannel)context.DiscordChannel).IsNsfw;
Expand Down Expand Up @@ -284,6 +289,10 @@ public ChartBuilders(ChartService chartService, LastFmRepository lastFmRepositor
if (supporter != null)
{
response.Components = new ComponentBuilder().WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterOverviewLink);
if (PublicProperties.DiscordPurchaseLink != null)
{
response.Components.WithButton(Constants.GetDiscordSupporterButton, style: ButtonStyle.Link, url: PublicProperties.DiscordPurchaseLink);
}
}

var nsfwAllowed = context.DiscordGuild == null || ((SocketTextChannel)context.DiscordChannel).IsNsfw;
Expand Down
4 changes: 4 additions & 0 deletions src/FMBot.Bot/Builders/FriendBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ public async Task<ResponseModel> AddFriendsAsync(ContextModel context, string[]
$"Sorry, but you can't have more than {Constants.MaxFriends} friends. \n\n" +
$".fmbot supporters can add up to {Constants.MaxFriendsSupporter} friends. [Click here to view all perks of being a supporter]({Constants.GetSupporterOverviewLink}).");
response.Components = new ComponentBuilder().WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterOverviewLink);
if (PublicProperties.DiscordPurchaseLink != null)
{
response.Components.WithButton(Constants.GetDiscordSupporterButton, style: ButtonStyle.Link, url: PublicProperties.DiscordPurchaseLink);
}
}
else
{
Expand Down
20 changes: 17 additions & 3 deletions src/FMBot.Bot/Builders/StaticBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,36 @@ public StaticBuilders(SupporterService supporterService)
{
var lastPayment = DateTime.SpecifyKind(existingSupporter.LastPayment.Value, DateTimeKind.Utc);
var lastPaymentValue = ((DateTimeOffset)lastPayment).ToUnixTimeSeconds();
existingSupporterDescription.AppendLine($"Last payment: <t:{lastPaymentValue}:D>");

if (existingSupporter.SubscriptionType != SubscriptionType.Discord)
{
existingSupporterDescription.AppendLine($"Last payment: <t:{lastPaymentValue}:D>");
}
else
{
existingSupporterDescription.AppendLine($"Expires on: <t:{lastPaymentValue}:D>");
}
}

if (existingSupporter.SubscriptionType.HasValue)
{
existingSupporterDescription.AppendLine($"Subscription type: {Enum.GetName(existingSupporter.SubscriptionType.Value)}");
}

existingSupporterDescription.AppendLine($"Name: **{StringExtensions.Sanitize(existingSupporter.Name)}** (from OpenCollective)");
existingSupporterDescription.AppendLine($"Name: **{StringExtensions.Sanitize(existingSupporter.Name)}**");

response.Embed.AddField("Your details", existingSupporterDescription.ToString());
}

response.Embed.WithDescription(embedDescription.ToString());

response.Components = new ComponentBuilder().WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterLink);
var buttons = new ComponentBuilder().WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterLink);
if (PublicProperties.DiscordPurchaseLink != null)
{
buttons.WithButton(Constants.GetDiscordSupporterButton, style: ButtonStyle.Link, url: PublicProperties.DiscordPurchaseLink);
}

response.Components = buttons;

return response;
}
Expand Down
8 changes: 8 additions & 0 deletions src/FMBot.Bot/Builders/UserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public async Task<ResponseModel> FeaturedAsync(ContextModel context)
if (this._timer.CurrentFeatured.SupporterDay && context.ContextUser.UserType == UserType.User)
{
response.Components = new ComponentBuilder().WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterOverviewLink);
if (PublicProperties.DiscordPurchaseLink != null)
{
response.Components.WithButton(Constants.GetDiscordSupporterButton, style: ButtonStyle.Link, url: PublicProperties.DiscordPurchaseLink);
}
}

response.Embed.WithFooter($"View your featured history with '{context.Prefix}featuredlog'");
Expand Down Expand Up @@ -706,6 +710,10 @@ public async Task<ResponseModel> StatsAsync(ContextModel context, UserSettingsMo

response.Components = new ComponentBuilder()
.WithButton(Constants.GetSupporterButton, style: ButtonStyle.Link, url: Constants.GetSupporterLink);
if (PublicProperties.DiscordPurchaseLink != null)
{
response.Components.WithButton(Constants.GetDiscordSupporterButton, style: ButtonStyle.Link, url: PublicProperties.DiscordPurchaseLink);
}
}
}
else
Expand Down
1 change: 1 addition & 0 deletions src/FMBot.Bot/Configurations/ConfigData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static ConfigData()
Discord = new DiscordConfig
{
BotUserId = 0000000000000,
ApplicationId = 0000000000000,
Token = "CHANGE-ME-DISCORD-TOKEN"
},
LastFm = new LastFmConfig
Expand Down
3 changes: 2 additions & 1 deletion src/FMBot.Bot/FMBot.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@
<ProjectReference Include="..\FMBot.Domain\FMBot.Domain.csproj" />
<ProjectReference Include="..\FMBot.Images\FMBot.Images.csproj" />
<ProjectReference Include="..\FMBot.LastFM.Domain\FMBot.LastFM.Domain.csproj" />
<ProjectReference Include="..\FMBot.OpenCollective\FMBot.OpenCollective.csproj" />
<ProjectReference Include="..\FMBot.OpenCollective\FMBot.Subscriptions.csproj" />
<ProjectReference Include="..\FMBot.Persistence\FMBot.Persistence.csproj" />
<ProjectReference Include="..\FMBot.Persistence.Domain\FMBot.Persistence.Domain.csproj" />
<ProjectReference Include="..\FMBot.Persistence.EntityFrameWork\FMBot.Persistence.EntityFrameWork.csproj" />
<ProjectReference Include="..\FMBot.Logger\FMBot.Logger.csproj" />
<ProjectReference Include="..\FMBot.LastFM\FMBot.LastFM.csproj" />
<ProjectReference Include="..\FMBot.Subscriptions\FMBot.Subscriptions.csproj" />
<ProjectReference Include="..\FMBot.Youtube\FMBot.Youtube.csproj" />
<ProjectReference Include="..\FMBot.Logger\FMBot.Logger.csproj" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FMBot.Bot/Models/DiscogsModels.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using FMBot.Domain.Enums;

namespace FMBot.Bot.Models;

Expand Down Expand Up @@ -31,4 +31,4 @@ public DiscogsCollectionSettings(List<string> formats)
return (DiscogsFormat.Miscellaneous, null);
}
}
}
}
1 change: 1 addition & 0 deletions src/FMBot.Bot/Services/SettingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Discord.Commands;
using FMBot.Bot.Models;
using FMBot.Domain;
using FMBot.Domain.Enums;
using FMBot.Domain.Models;
using FMBot.Persistence.Domain.Models;
using FMBot.Persistence.EntityFrameWork;
Expand Down
Loading

0 comments on commit 5929567

Please sign in to comment.