Add initial code
This commit is contained in:
		
					parent
					
						
							
								0fa7859a41
							
						
					
				
			
			
				commit
				
					
						87a7aef368
					
				
			
		
					 12 changed files with 435 additions and 0 deletions
				
			
		
							
								
								
									
										8
									
								
								.idea/.gitignore
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.idea/.gitignore
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | ||||||
|  | # Default ignored files | ||||||
|  | /shelf/ | ||||||
|  | /workspace.xml | ||||||
|  | # Editor-based HTTP Client requests | ||||||
|  | /httpRequests/ | ||||||
|  | # Datasource local storage ignored files | ||||||
|  | /dataSources/ | ||||||
|  | /dataSources.local.xml | ||||||
							
								
								
									
										7
									
								
								.idea/discord.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.idea/discord.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="DiscordProjectSettings"> | ||||||
|  |     <option name="show" value="PROJECT_FILES" /> | ||||||
|  |     <option name="description" value="" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										7
									
								
								.idea/encodings.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.idea/encodings.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="Encoding"> | ||||||
|  |     <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> | ||||||
|  |     <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										14
									
								
								.idea/misc.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.idea/misc.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="ExternalStorageConfigurationManager" enabled="true" /> | ||||||
|  |   <component name="MavenProjectsManager"> | ||||||
|  |     <option name="originalFiles"> | ||||||
|  |       <list> | ||||||
|  |         <option value="$PROJECT_DIR$/pom.xml" /> | ||||||
|  |       </list> | ||||||
|  |     </option> | ||||||
|  |   </component> | ||||||
|  |   <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK"> | ||||||
|  |     <output url="file://$PROJECT_DIR$/out" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										124
									
								
								.idea/uiDesigner.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								.idea/uiDesigner.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,124 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="Palette2"> | ||||||
|  |     <group name="Swing"> | ||||||
|  |       <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> | ||||||
|  |         <initial-values> | ||||||
|  |           <property name="text" value="Button" /> | ||||||
|  |         </initial-values> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | ||||||
|  |         <initial-values> | ||||||
|  |           <property name="text" value="RadioButton" /> | ||||||
|  |         </initial-values> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | ||||||
|  |         <initial-values> | ||||||
|  |           <property name="text" value="CheckBox" /> | ||||||
|  |         </initial-values> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> | ||||||
|  |         <initial-values> | ||||||
|  |           <property name="text" value="Label" /> | ||||||
|  |         </initial-values> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | ||||||
|  |           <preferred-size width="150" height="-1" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | ||||||
|  |           <preferred-size width="150" height="-1" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | ||||||
|  |           <preferred-size width="150" height="-1" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="150" height="50" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="150" height="50" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="150" height="50" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="150" height="50" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="150" height="50" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="150" height="50" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="200" height="200" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | ||||||
|  |           <preferred-size width="200" height="200" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> | ||||||
|  |           <preferred-size width="-1" height="20" /> | ||||||
|  |         </default-constraints> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> | ||||||
|  |       </item> | ||||||
|  |       <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false"> | ||||||
|  |         <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> | ||||||
|  |       </item> | ||||||
|  |     </group> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										6
									
								
								.idea/vcs.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/vcs.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="VcsDirectoryMappings"> | ||||||
|  |     <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										34
									
								
								pom.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								pom.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
|  |          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
|  |     <modelVersion>4.0.0</modelVersion> | ||||||
|  | 
 | ||||||
|  |     <groupId>net.hypr</groupId> | ||||||
|  |     <artifactId>doki</artifactId> | ||||||
|  |     <version>1.0-SNAPSHOT</version> | ||||||
|  | 
 | ||||||
|  |     <properties> | ||||||
|  |         <maven.compiler.source>17</maven.compiler.source> | ||||||
|  |         <maven.compiler.target>17</maven.compiler.target> | ||||||
|  |         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||||
|  |     </properties> | ||||||
|  | 
 | ||||||
|  |     <dependencies> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>net.dv8tion</groupId> | ||||||
|  |             <artifactId>JDA</artifactId> | ||||||
|  |             <version>5.0.1</version> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>io.github.freya022</groupId> | ||||||
|  |             <artifactId>BotCommands</artifactId> | ||||||
|  |             <version>2.10.4</version> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.json</groupId> | ||||||
|  |             <artifactId>json</artifactId> | ||||||
|  |             <version>20231013</version> | ||||||
|  |         </dependency> | ||||||
|  |     </dependencies> | ||||||
|  | </project> | ||||||
							
								
								
									
										71
									
								
								src/main/java/net/hypr/doki/Config.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								src/main/java/net/hypr/doki/Config.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,71 @@ | ||||||
|  | package net.hypr.doki; | ||||||
|  | 
 | ||||||
|  | import com.google.gson.Gson; | ||||||
|  | 
 | ||||||
|  | import java.io.*; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  | import java.nio.file.Path; | ||||||
|  | 
 | ||||||
|  | //You can add more fields in this class, if your input json matches the structure | ||||||
|  | //You will need a valid config.json in the package com.freya02.bot for this to work | ||||||
|  | public class Config { | ||||||
|  |     @SuppressWarnings("unused") private String token; | ||||||
|  |     @SuppressWarnings("unused") private DBConfig dbConfig; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Returns the configuration object for this bot | ||||||
|  |      * | ||||||
|  |      * @return The config | ||||||
|  |      * @throws IOException if the config JSON could not be read | ||||||
|  |      */ | ||||||
|  |     public static Config readConfig() throws IOException { | ||||||
|  |         System.out.println(Path.of("config.json")); | ||||||
|  |         try (InputStream in=Thread.currentThread().getContextClassLoader().getResourceAsStream("config.json")) { | ||||||
|  |             assert in != null; | ||||||
|  |             Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8); | ||||||
|  |             return new Gson().fromJson(reader, Config.class); | ||||||
|  |         } catch (IOException e) { | ||||||
|  |             throw new IOException(""" | ||||||
|  | 					config.json was not found in the root folder (of the project), did you forget to put it ? | ||||||
|  | 					Example structure: | ||||||
|  | 
 | ||||||
|  | 					{ | ||||||
|  | 						"token": "[your_bot_token_here]" | ||||||
|  | 					} | ||||||
|  | 					""", e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public String getToken() { | ||||||
|  |         return token; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public DBConfig getDbConfig() { | ||||||
|  |         return dbConfig; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static class DBConfig { | ||||||
|  |         @SuppressWarnings("unused") private String serverName, user, password, dbName; | ||||||
|  |         @SuppressWarnings("unused") private int portNumber; | ||||||
|  | 
 | ||||||
|  |         public String getServerName() { | ||||||
|  |             return serverName; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public String getUser() { | ||||||
|  |             return user; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public String getPassword() { | ||||||
|  |             return password; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public String getDbName() { | ||||||
|  |             return dbName; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public int getPortNumber() { | ||||||
|  |             return portNumber; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										57
									
								
								src/main/java/net/hypr/doki/Doki.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/main/java/net/hypr/doki/Doki.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,57 @@ | ||||||
|  | package net.hypr.doki; | ||||||
|  | 
 | ||||||
|  | import com.freya02.botcommands.api.CommandsBuilder; | ||||||
|  | import com.freya02.botcommands.api.Logging; | ||||||
|  | import net.dv8tion.jda.api.JDA; | ||||||
|  | import net.dv8tion.jda.api.JDABuilder; | ||||||
|  | import net.dv8tion.jda.api.entities.*; | ||||||
|  | import net.dv8tion.jda.api.requests.GatewayIntent; | ||||||
|  | import org.slf4j.Logger; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | 
 | ||||||
|  | public class Doki { | ||||||
|  |     private static final Logger LOGGER = Logging.getLogger(); | ||||||
|  |     private static JDA jda; | ||||||
|  |     private static Config config; | ||||||
|  | 
 | ||||||
|  |     private Doki(JDA jda, Config config) { | ||||||
|  |         Doki.jda = jda; | ||||||
|  |         Doki.config = config; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public JDA getJDA() { | ||||||
|  |         return jda; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static Doki start() throws IOException, InterruptedException { | ||||||
|  |         config = Config.readConfig(); | ||||||
|  | 
 | ||||||
|  |         final JDA jda = JDABuilder.createLight(config.getToken()) | ||||||
|  |                 .setActivity(Activity.customStatus("Banned from everywhere")) | ||||||
|  |                 .enableIntents(GatewayIntent.MESSAGE_CONTENT) | ||||||
|  |                 .build() | ||||||
|  |                 .awaitReady(); | ||||||
|  | 
 | ||||||
|  |         //Print some information about the bot | ||||||
|  |         LOGGER.info("Bot connected as {}", jda.getSelfUser().getAsTag()); | ||||||
|  |         LOGGER.info("The bot is present on these guilds :"); | ||||||
|  |         for (Guild guild : jda.getGuildCache()) { | ||||||
|  |             LOGGER.info("\t- {} ({})", guild.getName(), guild.getId()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return new Doki(jda, config); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static void main(String[] args) { | ||||||
|  |         try { | ||||||
|  |             jda = start().getJDA(); | ||||||
|  |             CommandsBuilder.newBuilder(437970062922612737L) | ||||||
|  |                     .textCommandBuilder(textCommandsBuilder -> textCommandsBuilder.addPrefix("oki!")) | ||||||
|  |                     .build(jda, "net.hypr.doki.commands"); //Registering listeners is taken care of by the lib | ||||||
|  |         } catch (Exception e) { | ||||||
|  |             LOGGER.error("Unable to start the bot", e); | ||||||
|  |             System.exit(-1); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										43
									
								
								src/main/java/net/hypr/doki/commands/About.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/main/java/net/hypr/doki/commands/About.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | ||||||
|  | package net.hypr.doki.commands; | ||||||
|  | 
 | ||||||
|  | import com.freya02.botcommands.api.prefixed.CommandEvent; | ||||||
|  | import com.freya02.botcommands.api.prefixed.TextCommand; | ||||||
|  | import com.freya02.botcommands.api.prefixed.annotations.Category; | ||||||
|  | import com.freya02.botcommands.api.prefixed.annotations.Description; | ||||||
|  | import com.freya02.botcommands.api.prefixed.annotations.JDATextCommand; | ||||||
|  | import net.dv8tion.jda.api.EmbedBuilder; | ||||||
|  | import net.dv8tion.jda.api.JDA; | ||||||
|  | import net.dv8tion.jda.api.entities.SelfUser; | ||||||
|  | 
 | ||||||
|  | import java.awt.*; | ||||||
|  | 
 | ||||||
|  | @Category("Misc") | ||||||
|  | @Description("Get about info") | ||||||
|  | public class About extends TextCommand { | ||||||
|  |     @JDATextCommand(name = "about") | ||||||
|  |     public void execute(CommandEvent event) { | ||||||
|  |         JDA jda = event.getJDA(); | ||||||
|  |         SelfUser selfUser = jda.getSelfUser(); | ||||||
|  |         String jdaVersion = ""; | ||||||
|  |         try { | ||||||
|  |             Class<?> jdaClass = Class.forName("net.dv8tion.jda.api.JDA"); | ||||||
|  |             Package jdaPackage = jdaClass.getPackage(); | ||||||
|  |             if (jdaPackage != null) { | ||||||
|  |                 // Attempt to get Implementation-Version from the manifest | ||||||
|  |                 String version = jdaPackage.getImplementationVersion(); | ||||||
|  |                 jdaVersion = version != null ? version : "Unknown"; | ||||||
|  |             } | ||||||
|  |         } catch (Exception ex) { | ||||||
|  |             jdaVersion = "UNKNOWN"; | ||||||
|  |         } | ||||||
|  |         EmbedBuilder aboutEmbed = new EmbedBuilder() | ||||||
|  |                 .setTitle("About " + selfUser.getName()) | ||||||
|  |                 .setThumbnail(selfUser.getAvatarUrl()) | ||||||
|  |                 .setDescription("Banned from every deli nationwide") | ||||||
|  |                 .addField("Guilds", String.valueOf(jda.getGuildCache().stream().count()), true) | ||||||
|  |                 .addField("JDA Version", jdaVersion, true) | ||||||
|  |                 .addField("Owner", "fwoppydwisk", true) | ||||||
|  |                 .setColor(new Color(210,138,39)); | ||||||
|  |             event.reply(aboutEmbed.build()).queue(); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										19
									
								
								src/main/java/net/hypr/doki/commands/Ping.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/main/java/net/hypr/doki/commands/Ping.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | ||||||
|  | package net.hypr.doki.commands; | ||||||
|  | 
 | ||||||
|  | import com.freya02.botcommands.api.prefixed.CommandEvent; | ||||||
|  | import com.freya02.botcommands.api.prefixed.TextCommand; | ||||||
|  | import com.freya02.botcommands.api.prefixed.annotations.Category; | ||||||
|  | import com.freya02.botcommands.api.prefixed.annotations.Description; | ||||||
|  | import com.freya02.botcommands.api.prefixed.annotations.JDATextCommand; | ||||||
|  | 
 | ||||||
|  | @Category("Misc") | ||||||
|  | @Description("Pong!") | ||||||
|  | public class Ping extends TextCommand { | ||||||
|  |     @JDATextCommand(name = "ping") | ||||||
|  |     public void execute(CommandEvent event) { | ||||||
|  |         final long gatewayPing = event.getJDA().getGatewayPing(); | ||||||
|  | 
 | ||||||
|  |         event.getJDA().getRestPing() | ||||||
|  |                 .queue(restPing -> event.respondFormat("Gateway ping: **%d ms**\nRest ping: **%d ms**", gatewayPing, restPing).queue()); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										45
									
								
								src/main/resources/logback.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/main/resources/logback.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <configuration> | ||||||
|  |     <timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/> | ||||||
|  | 
 | ||||||
|  |     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||||||
|  |         <encoder> | ||||||
|  |             <!-- Debug pattern --> | ||||||
|  |             <!--<pattern>%d{HH:mm:ss.SSS} %boldCyan(%-26.-26thread) %boldRed(%-36.-36class{36}) %boldRed(#%-24.-24method{24}) %boldRed(L%-5.-5line) %boldYellow(%-20.-20logger{0}) %highlight(%-6level) %msg%n%throwable</pattern>--> | ||||||
|  |             <!-- Normal pattern, no stack frames --> | ||||||
|  |             <pattern>%d{HH:mm:ss.SSS} %boldCyan(%-26.-26thread) %boldYellow(%-20.-20logger{0}) %highlight(%-6level) %msg%n%throwable</pattern> | ||||||
|  |         </encoder> | ||||||
|  |     </appender> | ||||||
|  | 
 | ||||||
|  |     <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||||||
|  |         <file>logs/latest.log</file> | ||||||
|  |         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||||||
|  |             <!-- daily rollover --> | ||||||
|  |             <fileNamePattern>logs/logs-%d{yyyy-MM-dd}.log</fileNamePattern> | ||||||
|  | 
 | ||||||
|  |             <!-- keep 90 days' worth of history capped at 3GB total size --> | ||||||
|  |             <maxHistory>90</maxHistory> | ||||||
|  |             <totalSizeCap>3GB</totalSizeCap> | ||||||
|  |         </rollingPolicy> | ||||||
|  | 
 | ||||||
|  |         <encoder> | ||||||
|  |             <pattern>%d{HH:mm:ss.SSS} %-26.-26thread %-36.-36class{36} #%-24.-24method{24} L%-5.-5line %-20.-20logger{0} %-6level %msg%n%throwable</pattern> | ||||||
|  |         </encoder> | ||||||
|  |     </appender> | ||||||
|  | 
 | ||||||
|  |     <!-- Log JDA and HikariCP on Info while others are on Debug --> | ||||||
|  |     <logger name="net.dv8tion.jda" level="info" additivity="false"> | ||||||
|  |         <appender-ref ref="STDOUT"/> | ||||||
|  |         <appender-ref ref="FILE"/> | ||||||
|  |     </logger> | ||||||
|  | 
 | ||||||
|  |     <logger name="com.zaxxer.hikari" level="info" additivity="false"> | ||||||
|  |         <appender-ref ref="STDOUT"/> | ||||||
|  |         <appender-ref ref="FILE"/> | ||||||
|  |     </logger> | ||||||
|  | 
 | ||||||
|  |     <root level="debug"> | ||||||
|  |         <appender-ref ref="STDOUT"/> | ||||||
|  |         <appender-ref ref="FILE"/> | ||||||
|  |     </root> | ||||||
|  | </configuration> | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Frankie B
				Frankie B