Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Donation System #195

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
ef91525
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Jul 19, 2019
5347be0
Start work on moving stuff over to new system
weeryan17 Jul 20, 2019
fd91f5b
More work on figuring out how this is going to work.
weeryan17 Jul 24, 2019
8a0a3e6
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Jul 24, 2019
cd806a6
teirs woo!
weeryan17 Jul 30, 2019
2018cd0
Make it compile
weeryan17 Jul 31, 2019
0a46f3e
actually be able to load and save
weeryan17 Aug 1, 2019
bf9f2b9
Add flag checking
weeryan17 Aug 3, 2019
e3336af
Start organizing data better
weeryan17 Aug 3, 2019
15ce59f
User data
weeryan17 Aug 3, 2019
7b8c912
start basic default tier structure
weeryan17 Aug 17, 2019
601c309
Implement the rest of the default tiers
weeryan17 Aug 20, 2019
e3c5a85
Language stuff
weeryan17 Aug 20, 2019
079bc61
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Aug 31, 2019
6ed8c21
Gotta love it when merges break stuff
weeryan17 Aug 31, 2019
0034434
All the interfaces
weeryan17 Sep 5, 2019
b2680cb
Merge branch 'release/beta' into feature/donation-stuffs
binaryoverload Sep 19, 2019
8be8618
Implement a whole bunch of flag changes (See description)
binaryoverload Sep 28, 2019
4524fa6
Goodbye old tiers
weeryan17 Nov 5, 2019
468c2d2
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Nov 6, 2019
243672e
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Nov 9, 2019
475a64d
A lot of stuff
weeryan17 Nov 9, 2019
965126d
Implement tier getting and storage
weeryan17 Nov 9, 2019
5667b6a
Implement multiple users per guild
weeryan17 Nov 9, 2019
d3487ec
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Nov 10, 2019
10e5725
Implement getting tier features as string
weeryan17 Nov 10, 2019
2fc1c0f
parent likes being null
weeryan17 Nov 10, 2019
69502d1
goodbuy patreon
weeryan17 Nov 11, 2019
0211d62
Add scope to everything
weeryan17 Nov 11, 2019
63134cb
Implement flags on commands
weeryan17 Nov 11, 2019
5332d06
whops wrong language path
weeryan17 Nov 11, 2019
ce94808
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Nov 14, 2019
392b243
Implement all flags I can implement right now
weeryan17 Nov 14, 2019
18d7a4b
goodbye guild flag command
weeryan17 Nov 14, 2019
9cde015
whops
weeryan17 Nov 14, 2019
b8e6651
wat
weeryan17 Nov 14, 2019
b2e9221
hasFlag method instead of null checks
weeryan17 Nov 14, 2019
b19bd43
Update src/main/resources/default_tiers.json
weeryan17 Nov 14, 2019
ae0cf0d
Fix some things
weeryan17 Nov 14, 2019
7282cf2
Merge remote-tracking branch 'origin/feature/donation-stuffs' into fe…
weeryan17 Nov 14, 2019
0f4ac4f
More fixes
weeryan17 Nov 14, 2019
a668231
Stay in voice channel flag
weeryan17 Nov 15, 2019
f023107
Whops missed a variable
weeryan17 Nov 15, 2019
bc9a7e2
Update src/main/java/org/cascadebot/cascadebot/data/managers/CascadeU…
weeryan17 Nov 15, 2019
721f180
useless method
weeryan17 Nov 15, 2019
2fdf1f5
Merge remote-tracking branch 'origin/feature/donation-stuffs' into fe…
weeryan17 Nov 15, 2019
9d6aaa1
fix documentation
weeryan17 Nov 15, 2019
5031f15
fix inconsistency
weeryan17 Nov 15, 2019
3f9206c
use string utils instead of null check
weeryan17 Nov 15, 2019
ac4aa5d
metrics
weeryan17 Nov 15, 2019
751be7b
Settings required flags
weeryan17 Nov 15, 2019
6196adf
fixed a small issue
weeryan17 Nov 15, 2019
34c163a
remove unneeded method
weeryan17 Nov 22, 2019
a65b833
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Nov 22, 2019
3639646
Implement tier for those who boost the guild
weeryan17 Dec 8, 2019
1f58530
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Dec 12, 2019
ec5bc12
Add donation perks
JamesHawkinss Dec 13, 2019
3b30b4c
Filter out default and nitro
JamesHawkinss Dec 13, 2019
6063320
Review
JamesHawkinss Dec 22, 2019
991f5e5
Add new line at end of file
JamesHawkinss Dec 22, 2019
168dee3
Merge pull request #200 from JamesHawkinss/feature/donation-stuffs
binaryoverload Dec 23, 2019
7f097f8
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Jan 5, 2020
ad37de1
Use source names from music handler
weeryan17 Jan 5, 2020
31bf5ee
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Jan 18, 2020
1a3fba9
Fix Compile Issues
weeryan17 Jan 18, 2020
8b82328
Implement manual tier so the owners can set a tier
weeryan17 Jan 18, 2020
15b4a7b
Equlizer needs a flag
weeryan17 Jan 18, 2020
84bf24e
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Mar 8, 2020
024ff7f
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Apr 18, 2020
31f1680
Fix up merge
weeryan17 Apr 18, 2020
86dc495
Merge branch 'dev' into feature/donation-stuffs
weeryan17 Apr 28, 2020
0ee3755
Make it actually compile
weeryan17 Apr 28, 2020
83e93c2
Fix up everything, and work on new stuff
weeryan17 Apr 28, 2020
f534b2d
Flag container
weeryan17 Apr 28, 2020
d937dc3
Todo-list kotlinifcations
binaryoverload Apr 28, 2020
4b63f56
CascadeUser kotlinification
binaryoverload Apr 28, 2020
6ba6157
GuildData: kotlinification
binaryoverload Apr 28, 2020
a796ea5
Kotlinification of flags + tiers
binaryoverload Apr 28, 2020
0449a4f
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 1, 2020
8df56a0
Fix up things
weeryan17 May 1, 2020
4ab279e
Interaction with patreon service
weeryan17 May 1, 2020
a7f33b7
Stop wildcard imports
weeryan17 May 1, 2020
576ca61
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 3, 2020
2623bae
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 3, 2020
b9f1f51
Fix merge issues
weeryan17 May 3, 2020
8a73fc9
Move stuff to new proper package
weeryan17 May 3, 2020
ab6536f
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 4, 2020
53468ec
Fix Merge
weeryan17 May 4, 2020
305007c
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 4, 2020
672b946
Fix null issues with donation string stuff
weeryan17 May 6, 2020
22b4fcb
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 6, 2020
8920f54
Merge branch 'dev' into feature/donation-stuffs
weeryan17 May 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/org/cascadebot/cascadebot/CascadeBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import org.cascadebot.cascadebot.commandmeta.CommandManager;
import org.cascadebot.cascadebot.data.Config;
import org.cascadebot.cascadebot.data.database.DatabaseManager;
import org.cascadebot.cascadebot.data.managers.CascadeUserDataManager;
import org.cascadebot.cascadebot.data.managers.GuildDataManager;
import org.cascadebot.cascadebot.data.objects.donation.Tier;
import org.cascadebot.cascadebot.events.ButtonEventListener;
import org.cascadebot.cascadebot.events.CommandListener;
import org.cascadebot.cascadebot.events.GeneralEventListener;
Expand Down Expand Up @@ -200,6 +202,8 @@ private void init() {
defaultShardManagerBuilder.setAudioSendFactory(new NativeAudioSendFactory());
}

Tier.Companion.parseTiers();

shardManager = defaultShardManagerBuilder.build();
} catch (LoginException e) {
LOGGER.error("Error building JDA", e);
Expand All @@ -215,6 +219,7 @@ private void init() {
moderationManager = new ModerationManager();

Metrics.INS.cacheMetrics.addCache("guilds", GuildDataManager.getGuilds());
Metrics.INS.cacheMetrics.addCache("users", CascadeUserDataManager.getUsers());

Thread.setDefaultUncaughtExceptionHandler(((t, e) -> LOGGER.error("Uncaught exception in thread " + t, MDCException.from(e))));
Thread.currentThread()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.apache.commons.lang3.reflect.ConstructorUtils;
import org.cascadebot.cascadebot.ShutdownHandler;
import org.cascadebot.cascadebot.data.language.Locale;
import org.cascadebot.cascadebot.data.objects.GuildData;
import org.cascadebot.cascadebot.data.objects.guild.GuildData;
import org.cascadebot.cascadebot.utils.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.dv8tion.jda.api.entities.Member;
import org.cascadebot.cascadebot.data.language.Language;
import org.cascadebot.cascadebot.data.language.Locale;
import org.cascadebot.cascadebot.data.objects.Flag;
import org.cascadebot.cascadebot.data.objects.donation.Flag;
import org.cascadebot.cascadebot.permissions.CascadePermission;

import java.util.Set;
Expand Down Expand Up @@ -61,8 +61,8 @@ default boolean deleteMessages() {
return true;
}

default Set<Flag> getFlags() {
return Set.of();
default String getRequiredFlag() {
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.cascadebot.cascadebot.commands.core;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
import org.apache.commons.lang3.StringUtils;
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ICommandCore;
import org.cascadebot.cascadebot.data.objects.donation.Tier;
import org.cascadebot.cascadebot.messaging.MessagingObjects;
import org.cascadebot.cascadebot.utils.pagination.Page;
import org.cascadebot.cascadebot.utils.pagination.PageObjects;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DonateCommand implements ICommandCore {

@Override
public void onCommand(Member sender, CommandContext context) {
EmbedBuilder builder = MessagingObjects.getClearThreadLocalEmbedBuilder();
List<Page> pages = new ArrayList<>();

builder.setTitle(context.i18n("commands.donate.embed_title"));
builder.setDescription(context.i18n("commands.donate.embed_description"));
builder.setFooter(context.i18n("commands.donate.embed_footer"), context.getSelfUser().getAvatarUrl());
builder.addField("Patreon", context.i18n("commands.donate.embed_patreon"), true);

pages.add(new PageObjects.EmbedPage(builder));
for (Map.Entry<String, Tier> tier : Tier.Companion.getTiers().entrySet()) {
if (tier.getKey().equals("default") || tier.getKey().equals("nitro")) {
continue;
}
String title = tier.getKey();
pages.add(new PageObjects.EmbedPage(new EmbedBuilder()
.setDescription((tier.getValue().getGuildTierString(context.getLocale(), null)))
.setTitle(StringUtils.capitalize(title))
));
}

context.getUiMessaging().sendPagedMessage(pages);
}

@Override
public String command() {
return "donate";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ICommandCore;
import org.cascadebot.cascadebot.data.Config;
import org.cascadebot.cascadebot.data.objects.donation.AmountFlag;

public class PrefixCommand implements ICommandCore {

Expand All @@ -32,7 +33,12 @@ public void onCommand(Member sender, CommandContext context) {
return;
}

if (newPrefix.length() > 5) {
AmountFlag prefixFlag = (AmountFlag) context.getData().getAllFlags().getFlag("prefix_length");
if (prefixFlag == null) {
context.getTypedMessaging().replyDanger(context.i18n("commands.prefix.prefix_too_long"));
return;
}
if (newPrefix.length() > prefixFlag.getAmount()) {
context.getTypedMessaging().replyDanger(context.i18n("commands.prefix.prefix_too_long"));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void onCommand(Member sender, CommandContext context) {
scriptEngine.put("context", context);
scriptEngine.put("channel", context.getChannel());
scriptEngine.put("guild", context.getGuild());
scriptEngine.put("data", context.getData());

String imports = IMPORTS.stream().map(s -> "import " + s + ".*;").collect(Collectors.joining(" "));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SecurityLevel getCommandLevel() {

@Override
public Set<ISubCommand> getSubCommands() {
return Set.of(new GuildSaveSubCommand(), new GuildLeaveSubCommand(), new GuildFlagSubCommand(), new GuildInfoSubCommand());
return Set.of(new GuildSaveSubCommand(), new GuildLeaveSubCommand(), new GuildInfoSubCommand());
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.cascadebot.cascadebot.commandmeta.ISubCommand;
import org.cascadebot.cascadebot.commandmeta.Module;
import org.cascadebot.cascadebot.data.managers.GuildDataManager;
import org.cascadebot.cascadebot.data.objects.Flag;
import org.cascadebot.cascadebot.data.objects.GuildData;
import org.cascadebot.cascadebot.data.objects.guild.GuildData;
import org.cascadebot.cascadebot.messaging.MessagingObjects;
import org.cascadebot.cascadebot.permissions.CascadePermission;
import org.cascadebot.cascadebot.utils.FormatUtils;
Expand Down Expand Up @@ -45,18 +44,20 @@ public void onCommand(Member sender, CommandContext context) {


GuildData finalDataForList = dataForList;
/*
String flags = Arrays.stream(Flag.values())
.map(flag -> FormatUtils.formatEnum(flag) + " - " +
(finalDataForList.isFlagEnabled(flag) ? UnicodeConstants.TICK : UnicodeConstants.RED_CROSS))
.collect(Collectors.joining("\n"));
*/
weeryan17 marked this conversation as resolved.
Show resolved Hide resolved

String modules = Arrays.stream(Module.values())
.map(module -> FormatUtils.formatEnum(module) + " - " +
(finalDataForList.getCoreSettings().isModuleEnabled(module) ? UnicodeConstants.TICK : UnicodeConstants.RED_CROSS))
.collect(Collectors.joining("\n"));


builder.addField("Flags", flags, false);
//builder.addField("Flags", flags, false);
weeryan17 marked this conversation as resolved.
Show resolved Hide resolved
builder.addField("Modules", modules, false);
builder.addField("Join Date", FormatUtils.formatDateTime(context.getSelfMember().getTimeJoined()), false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ISubCommand;
import org.cascadebot.cascadebot.data.managers.GuildDataManager;
import org.cascadebot.cascadebot.data.objects.GuildData;
import org.cascadebot.cascadebot.data.objects.guild.GuildData;
import org.cascadebot.cascadebot.permissions.CascadePermission;

public class GuildSaveSubCommand implements ISubCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
package org.cascadebot.cascadebot.commands.management;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import org.apache.commons.lang3.StringUtils;
import org.cascadebot.cascadebot.UnicodeConstants;
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ICommandMain;
import org.cascadebot.cascadebot.commandmeta.Module;
import org.cascadebot.cascadebot.data.objects.Flag;
import org.cascadebot.cascadebot.data.objects.GuildData;
import org.cascadebot.cascadebot.messaging.MessagingObjects;
import org.cascadebot.cascadebot.permissions.CascadePermission;
import org.cascadebot.cascadebot.utils.FormatUtils;

import java.util.Arrays;
import java.util.stream.Collectors;

public class FlagsCommand implements ICommandMain {
weeryan17 marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void onCommand(Member sender, CommandContext context) {
/*
weeryan17 marked this conversation as resolved.
Show resolved Hide resolved
GuildData dataForList = context.getData();
Guild guildForList = context.getGuild();

Expand All @@ -36,6 +26,7 @@ public void onCommand(Member sender, CommandContext context) {
builder.addField(context.i18n("words.flags"), flags, false);

context.getTypedMessaging().replyInfo(builder);
*/
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public void onCommand(Member sender, CommandContext context) {
try {
Setting settingAnnotation = field.getAnnotation(Setting.class);
if (settingAnnotation != null) {
if (!context.getData().getEnabledFlags().containsAll(Arrays.asList(settingAnnotation.flagRequired()))) {
String niceName = Language.i18n(context.getGuild().getIdLong(), "settings." + field.getDeclaringClass().getAnnotation(SettingsContainer.class).module().name().toLowerCase() + "." + field.getName() + ".nice_name");
context.getTypedMessaging().replyDanger(context.i18n("commands.settings.cannot_edit", niceName));
return;
for (String flag : settingAnnotation.flagsRequired()) {
if (!context.getData().getAllFlags().hasFlag(flag)) {
String niceName = Language.i18n(context.getGuild().getIdLong(), "settings." + field.getDeclaringClass().getAnnotation(SettingsContainer.class).module().name().toLowerCase() + "." + field.getName() + ".nice_name");
context.getTypedMessaging().replyDanger(context.i18n("commands.settings.cannot_edit", niceName));
return;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ISubCommand;
import org.cascadebot.cascadebot.commandmeta.Module;
import org.cascadebot.cascadebot.data.objects.GuildPermissions;
import org.cascadebot.cascadebot.data.objects.guild.GuildPermissions;
import org.cascadebot.cascadebot.permissions.CascadePermission;
import org.cascadebot.cascadebot.permissions.objects.Group;
import org.cascadebot.cascadebot.utils.pagination.Page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ISubCommand;
import org.cascadebot.cascadebot.commandmeta.Module;
import org.cascadebot.cascadebot.data.objects.GuildPermissions;
import org.cascadebot.cascadebot.data.objects.guild.GuildPermissions;
import org.cascadebot.cascadebot.permissions.CascadePermission;
import org.cascadebot.cascadebot.permissions.objects.Group;
import org.cascadebot.cascadebot.utils.PermissionCommandUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.cascadebot.cascadebot.commandmeta.CommandContext;
import org.cascadebot.cascadebot.commandmeta.ISubCommand;
import org.cascadebot.cascadebot.commandmeta.Module;
import org.cascadebot.cascadebot.data.objects.GuildPermissions;
import org.cascadebot.cascadebot.data.objects.guild.GuildPermissions;
import org.cascadebot.cascadebot.permissions.CascadePermission;
import org.cascadebot.cascadebot.utils.FormatUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,10 @@ public CascadePermission getPermission() {
public Set<ISubCommand> getSubCommands() {
return Set.of(new EqualizerResetSubCommand());
}

@Override
public String getRequiredFlag() {
return "music_controls";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ public CascadePermission getPermission() {
return CascadePermission.of("equalizer.reset", true);
}

@Override
public String getRequiredFlag() {
return "music_controls";
}

}
Loading