Skip to content

Commit

Permalink
Merge pull request #55 from Softawii/feature/voice
Browse files Browse the repository at this point in the history
Voice Dinamico
  • Loading branch information
yaansz authored Aug 7, 2022
2 parents 75e3362 + c9b0ad2 commit 6d2d631
Show file tree
Hide file tree
Showing 17 changed files with 1,740 additions and 16 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ plugins {
}

group 'com.softwaii.capivara'
version '1.0.3.3'
version '1.0.4.0'


repositories {
mavenCentral()
Expand Down Expand Up @@ -34,8 +35,8 @@ dependencies {
exclude module: 'opus-java'
}

implementation("com.github.Softawii:curupira:v0.2.2:all")

implementation("com.github.Softawii:curupira:v0.2.6")
implementation("com.github.Softawii:curupira:v0.2.6:all")
implementation("com.github.minndevelopment:emoji-java:master-SNAPSHOT")
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/softawii/capivara/Main.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.softawii.capivara;

import com.softawii.capivara.core.EmbedManager;
import com.softawii.capivara.core.PackageManager;
import com.softawii.capivara.core.*;
import com.softawii.capivara.listeners.EchoGroup;
import com.softawii.capivara.core.TemplateManager;
import com.softawii.capivara.listeners.PackageGroup;
import com.softawii.capivara.listeners.TemplateGroup;
import com.softawii.capivara.listeners.VoiceGroup;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Activity;
import org.springframework.boot.CommandLineRunner;
Expand All @@ -25,10 +24,14 @@ public static void main(String[] args) {
BuildProperties buildProperties = context.getBean(BuildProperties.class);
jda.getPresence().setPresence(Activity.of(Activity.ActivityType.WATCHING,buildProperties.getVersion()), true);
System.out.println(buildProperties.getVersion() + " Bot is ready as " + jda.getSelfUser().getName());

// Beans
PackageGroup.packageManager = context.getBean(PackageManager.class);
EchoGroup.embedManager = context.getBean(EmbedManager.class);
PackageGroup.embedManager = EchoGroup.embedManager;
TemplateGroup.templateManager = context.getBean(TemplateManager.class);
VoiceGroup.Dynamic.voiceManager = context.getBean(VoiceManager.class);
VoiceGroup.Dynamic.droneManager = context.getBean(DroneManager.class);
}

@Override
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/softawii/capivara/config/SpringConfig.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.softawii.capivara.config;

import com.softawii.capivara.Main;
import com.softawii.capivara.core.PackageManager;
import com.softawii.capivara.listeners.PackageGroup;
import com.softawii.capivara.listeners.TemplateGroup;
import com.softawii.capivara.listeners.VoiceGroup;
import com.softawii.capivara.listeners.events.VoiceEvents;
import com.softawii.curupira.core.Curupira;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
Expand Down Expand Up @@ -44,7 +49,7 @@ public SpringConfig(Environment env) {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("com.softawii.capivara.entity","com.softawii.capivara.repository", "com.softawii.capivara.services");
em.setPackagesToScan("com.softawii.capivara.entity","com.softawii.capivara.repository", "com.softawii.capivara.services", "com.softawii.capivara.listeners.events");

JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
Expand All @@ -57,16 +62,16 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
private String discordToken;

@Bean
public JDA jda() {
public JDA jda(VoiceEvents voiceEvents) {
JDA jda;
try {
JDABuilder builder = JDABuilder.create(discordToken, GatewayIntent.GUILD_MEMBERS);
builder.enableIntents(GatewayIntent.GUILD_EMOJIS_AND_STICKERS);
JDABuilder builder = JDABuilder.create(discordToken, GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.GUILD_EMOJIS_AND_STICKERS, GatewayIntent.GUILD_PRESENCES);
builder.setMemberCachePolicy(MemberCachePolicy.ALL);
builder.enableCache(CacheFlag.EMOJI, CacheFlag.ROLE_TAGS, CacheFlag.MEMBER_OVERRIDES, CacheFlag.STICKER);
builder.addEventListeners(
new PackageGroup.AutoCompleter(),
new TemplateGroup.AutoCompleter()
new TemplateGroup.AutoCompleter(),
voiceEvents
);
jda = builder.build();
jda.awaitReady();
Expand All @@ -78,17 +83,14 @@ public JDA jda() {
}

@Bean
public Curupira curupira() {
JDA jda = jda();
public Curupira curupira(JDA jda) {
String pkg = "com.softawii.capivara.listeners";
String resetEnv = env.getProperty("curupira.reset", "false");
boolean reset = Boolean.parseBoolean(resetEnv);

System.out.println("Reset: " + reset);

Curupira curupira = new Curupira(jda, reset, null, pkg);

return curupira;
return new Curupira(jda, reset, null, pkg);
}


Expand Down
Loading

0 comments on commit 6d2d631

Please sign in to comment.