Skip to content

Commit eef0874

Browse files
committed
initial commit:
- added AutoCodeFormatter.java - added a preference for enabling/disabling AutoCodeFormatter - added a Setting in HelpConfig: hint for when users don't format their code - added a Setting in HelpConfig: footnote for when code has been autoformatted - edited HelpListener to include a call to AutoCodeFormatter.java - moved replaceMemberMessage from HugListener to WebhookUtil to allow usage from within AutoCodeFormatter.java
1 parent 7da14d1 commit eef0874

File tree

6 files changed

+542
-427
lines changed

6 files changed

+542
-427
lines changed

src/main/java/net/javadiscord/javabot/data/config/guild/HelpConfig.java

Lines changed: 121 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -15,113 +15,125 @@
1515
@Data
1616
@EqualsAndHashCode(callSuper = true)
1717
public class HelpConfig extends GuildConfigItem {
18-
private long helpForumChannelId = 0;
19-
20-
/**
21-
* The id of the helper role.
22-
*/
23-
private long helperRoleId;
24-
25-
/**
26-
* The id of the help-ping role.
27-
*/
28-
private long helpNotificationChannelId;
29-
30-
/**
31-
* The message that's sent as soon as a user asks a question in an open help
32-
* channel. This is only sent if it's not null.
33-
*/
34-
private String reservedChannelMessageTemplate = "`⌛` **This post has been reserved for your question.**\n> Hey %s! Please use `/close` or the `Close Post` button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after %s minutes of inactivity.\n\n**TIP:** Narrow down your issue to __simple__ and __precise__ questions to maximize the chance that others will reply in here.";
35-
36-
/**
37-
* The message that's sent in a post to tell users that it
38-
* is now marked as dormant and no more messages can be sent.
39-
*/
40-
private String dormantChannelMessageTemplate = "`\uD83D\uDCA4` **Post marked as dormant**\n> This post has been inactive for over %s minutes, thus, it has been **archived**.\n> If your question was not answered yet, feel free to re-open this post or create a new one.";
41-
42-
/**
43-
* The message that's sent in a post to tell users that it
44-
* is now marked as dormant and no more messages can be sent.
45-
*/
46-
private String dormantChannelPrivateMessageTemplate = """
47-
Your post %s in %s has been inactive for over %s minutes, thus, it has been **archived**.
48-
If your question was not answered yet, feel free to re-open this post by sending another message in that channel.
49-
You can disable notifications like this using the `/preferences` command.
50-
[Post link](%s)
51-
""";
52-
53-
54-
/**
55-
* The message that's sent when a user unreserved a channel where other users
56-
* participated in.
57-
*/
58-
private String helpThanksMessageTemplate = "Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click **I'm done here. Close this post!**.";
59-
60-
/**
61-
* The number of minutes of inactivity before a channel is considered inactive.
62-
*/
63-
private int inactivityTimeoutMinutes = 300;
64-
65-
/**
66-
* The number of minutes to wait before closing a channel waiting for a response
67-
* to a thanks question.
68-
*/
69-
private int removeThanksTimeoutMinutes = 10;
70-
71-
/**
72-
* How often users may use the /help-ping command.
73-
*/
74-
private int helpPingTimeoutSeconds = 300;
75-
76-
/**
77-
* The maximum amount of experience one can get from one help channel.
78-
*/
79-
private double maxExperiencePerChannel = 50;
80-
81-
/**
82-
* The base experience one gets for every message.
83-
*/
84-
private double baseExperience = 5;
85-
86-
/**
87-
* The weight for each character.
88-
*/
89-
private double perCharacterExperience = 1;
90-
91-
/**
92-
* The messages' minimum length.
93-
*/
94-
private int minimumMessageLength = 10;
95-
96-
/**
97-
* The amount of experience points one gets for being thanked by the help channel owner.
98-
*/
99-
private double thankedExperience = 50;
100-
101-
/**
102-
* The amount of experience one gets for thanking other users.
103-
*/
104-
private double thankExperience = 3;
105-
106-
/**
107-
* The amount that should be subtracted from every Help Account each day.
108-
*/
109-
private double dailyExperienceSubtraction = 5;
110-
111-
/**
112-
* A list with all roles that are awarded by experience.
113-
*/
114-
private Map<Long, Double> experienceRoles = Map.of(0L, 0.0);
115-
116-
public ForumChannel getHelpForumChannel() {
117-
return getGuild().getForumChannelById(helpForumChannelId);
118-
}
119-
120-
public Role getHelperRole() {
121-
return getGuild().getRoleById(helperRoleId);
122-
}
123-
124-
public TextChannel getHelpNotificationChannel() {
125-
return getGuild().getTextChannelById(helpNotificationChannelId);
126-
}
18+
private long helpForumChannelId = 0;
19+
20+
/**
21+
* The id of the helper role.
22+
*/
23+
private long helperRoleId;
24+
25+
/**
26+
* The id of the help-ping role.
27+
*/
28+
private long helpNotificationChannelId;
29+
30+
/**
31+
* The message that's sent as soon as a user asks a question in an open help
32+
* channel. This is only sent if it's not null.
33+
*/
34+
private String reservedChannelMessageTemplate = "`⌛` **This post has been reserved for your question.**\n> Hey %s! Please use `/close` or the `Close Post` button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after %s minutes of inactivity.\n\n**TIP:** Narrow down your issue to __simple__ and __precise__ questions to maximize the chance that others will reply in here.";
35+
36+
/**
37+
* The message that's sent in a post to tell users that it
38+
* is now marked as dormant and no more messages can be sent.
39+
*/
40+
private String dormantChannelMessageTemplate = "`\uD83D\uDCA4` **Post marked as dormant**\n> This post has been inactive for over %s minutes, thus, it has been **archived**.\n> If your question was not answered yet, feel free to re-open this post or create a new one.";
41+
42+
/**
43+
* The message that's sent in a post to tell users that it
44+
* is now marked as dormant and no more messages can be sent.
45+
*/
46+
private String dormantChannelPrivateMessageTemplate = """
47+
Your post %s in %s has been inactive for over %s minutes, thus, it has been **archived**.
48+
If your question was not answered yet, feel free to re-open this post by sending another message in that channel.
49+
You can disable notifications like this using the `/preferences` command.
50+
[Post link](%s)
51+
""";
52+
53+
/**
54+
* The message that is sent in a post to tell users that they
55+
* should use discord's code-formatting, provided the bot detects unformatted code.
56+
* Issued by {@link net.javadiscord.javabot.systems.help.AutoCodeFormatter}
57+
*/
58+
private String formatHintMessage = "> Please format your code to make it more readable. \n> For java, it should look like this: \n```\u200B`\u200B`\u200B`\u200Bjava\npublic void foo() {\n \n}\u200B`\u200B`\u200B`\u200B```";
59+
60+
/**
61+
* The message that's sent when a user unreserved a channel where other users
62+
* participated in.
63+
*/
64+
private String helpThanksMessageTemplate = "Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click **I'm done here. Close this post!**.";
65+
66+
/**
67+
* The number of minutes of inactivity before a channel is considered inactive.
68+
*/
69+
private int inactivityTimeoutMinutes = 300;
70+
71+
/**
72+
* The number of minutes to wait before closing a channel waiting for a response
73+
* to a thanks question.
74+
*/
75+
private int removeThanksTimeoutMinutes = 10;
76+
77+
/**
78+
* How often users may use the /help-ping command.
79+
*/
80+
private int helpPingTimeoutSeconds = 300;
81+
82+
/**
83+
* The maximum amount of experience one can get from one help channel.
84+
*/
85+
private double maxExperiencePerChannel = 50;
86+
87+
/**
88+
* The base experience one gets for every message.
89+
*/
90+
private double baseExperience = 5;
91+
92+
/**
93+
* The weight for each character.
94+
*/
95+
private double perCharacterExperience = 1;
96+
97+
/**
98+
* The messages' minimum length.
99+
*/
100+
private int minimumMessageLength = 10;
101+
102+
/**
103+
* The message-embed's footnote of an unformatted-code-replacement.
104+
* Issued by {@link net.javadiscord.javabot.systems.help.AutoCodeFormatter}
105+
*/
106+
private String autoformatInfoMessage = "This message has been formatted automatically.";
107+
108+
/**
109+
* The amount of experience points one gets for being thanked by the help channel owner.
110+
*/
111+
private double thankedExperience = 50;
112+
113+
/**
114+
* The amount of experience one gets for thanking other users.
115+
*/
116+
private double thankExperience = 3;
117+
118+
/**
119+
* The amount that should be subtracted from every Help Account each day.
120+
*/
121+
private double dailyExperienceSubtraction = 5;
122+
123+
/**
124+
* A list with all roles that are awarded by experience.
125+
*/
126+
private Map<Long, Double> experienceRoles = Map.of(0L, 0.0);
127+
128+
public ForumChannel getHelpForumChannel() {
129+
return getGuild().getForumChannelById(helpForumChannelId);
130+
}
131+
132+
public Role getHelperRole() {
133+
return getGuild().getRoleById(helperRoleId);
134+
}
135+
136+
public TextChannel getHelpNotificationChannel() {
137+
return getGuild().getTextChannelById(helpNotificationChannelId);
138+
}
127139
}

0 commit comments

Comments
 (0)