Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Soundboard #196

Open
wants to merge 4 commits into
base: 1.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.possible.Possible;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableSendSoundboardSoundRequest.class)
@JsonDeserialize(as = ImmutableSendSoundboardSoundRequest.class)
public interface SendSoundboardSoundRequest {

static ImmutableSendSoundboardSoundRequest.Builder builder() {
return ImmutableSendSoundboardSoundRequest.builder();
}

@JsonProperty("sound_id")
Id soundId();

@JsonProperty("source_guild_id")
Possible<Id> sourceGuildId();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.possible.Possible;
import java.util.Optional;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableSoundboardSoundCreateRequest.class)
@JsonDeserialize(as = ImmutableSoundboardSoundCreateRequest.class)
public interface SoundboardSoundCreateRequest {

static ImmutableSoundboardSoundCreateRequest.Builder builder() {
return ImmutableSoundboardSoundCreateRequest.builder();
}

String name();

String sound();

Possible<Optional<Double>> volume();

@JsonProperty("emoji_id")
Possible<Optional<Id>> emojiId();

@JsonProperty("emoji_name")
Possible<Optional<String>> emojiName();

}
41 changes: 41 additions & 0 deletions src/main/java/discord4j/discordjson/json/SoundboardSoundData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package discord4j.discordjson.json;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.possible.Possible;
import java.util.Optional;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableSoundboardSoundData.class)
@JsonDeserialize(as = ImmutableSoundboardSoundData.class)
public interface SoundboardSoundData {

static ImmutableSoundboardSoundData.Builder builder() {
return ImmutableSoundboardSoundData.builder();
}

String name();

@JsonProperty("sound_id")
Id soundId();

double volume();

@JsonProperty("emoji_id")
Optional<Id> emojiId();

@JsonProperty("emoji_name")
Optional<String> emojiName();

@JsonProperty("guild_id")
Possible<Id> guildId();

boolean available();

Possible<UserData> user();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.List;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableSoundboardSoundDataList.class)
@JsonDeserialize(as = ImmutableSoundboardSoundDataList.class)
public interface SoundboardSoundDataList {

static ImmutableSoundboardSoundDataList.Builder builder() {
return ImmutableSoundboardSoundDataList.builder();
}

List<SoundboardSoundData> items();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.possible.Possible;
import java.util.Optional;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableSoundboardSoundModifyRequest.class)
@JsonDeserialize(as = ImmutableSoundboardSoundModifyRequest.class)
public interface SoundboardSoundModifyRequest {

static ImmutableSoundboardSoundModifyRequest.Builder builder() {
return ImmutableSoundboardSoundModifyRequest.builder();
}

Possible<String> name();

Possible<String> sound();

Possible<Optional<Double>> volume();

@JsonProperty("emoji_id")
Possible<Optional<Id>> emojiId();

@JsonProperty("emoji_name")
Possible<Optional<String>> emojiName();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.json.SoundboardSoundData;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableGuildSoundboardSoundCreate.class)
@JsonDeserialize(as = ImmutableGuildSoundboardSoundCreate.class)
public interface GuildSoundboardSoundCreate extends Dispatch {

static ImmutableGuildSoundboardSoundCreate.Builder builder() {
return ImmutableGuildSoundboardSoundCreate.builder();
}

@JsonUnwrapped
SoundboardSoundData soundboardSound();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableGuildSoundboardSoundDelete.class)
@JsonDeserialize(as = ImmutableGuildSoundboardSoundDelete.class)
public interface GuildSoundboardSoundDelete extends Dispatch {

static ImmutableGuildSoundboardSoundDelete.Builder builder() {
return ImmutableGuildSoundboardSoundDelete.builder();
}

@JsonProperty("sound_id")
Id soundId();

@JsonProperty("guild_id")
Id guildId();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.json.SoundboardSoundData;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableGuildSoundboardSoundUpdate.class)
@JsonDeserialize(as = ImmutableGuildSoundboardSoundUpdate.class)
public interface GuildSoundboardSoundUpdate extends Dispatch {

static ImmutableGuildSoundboardSoundUpdate.Builder builder() {
return ImmutableGuildSoundboardSoundUpdate.builder();
}

@JsonUnwrapped
SoundboardSoundData soundboardSound();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.json.SoundboardSoundData;
import java.util.List;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableGuildSoundboardSoundsUpdate.class)
@JsonDeserialize(as = ImmutableGuildSoundboardSoundsUpdate.class)
public interface GuildSoundboardSoundsUpdate extends Dispatch {

static ImmutableGuildSoundboardSoundsUpdate.Builder builder() {
return ImmutableGuildSoundboardSoundsUpdate.builder();
}

@JsonProperty("soundboard_sounds")
List<SoundboardSoundData> soundboardSounds();

@JsonProperty("guild_id")
Id guildId();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import java.util.List;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableRequestSoundboardSounds.class)
@JsonDeserialize(as = ImmutableRequestSoundboardSounds.class)
public interface RequestSoundboardSounds extends PayloadData {

static ImmutableRequestSoundboardSounds.Builder builder() {
return ImmutableRequestSoundboardSounds.builder();
}

@JsonProperty("guild_ids")
List<Id> guildIds();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.json.SoundboardSoundData;
import java.util.List;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableGuildSoundboardSoundCreate.class)
@JsonDeserialize(as = ImmutableGuildSoundboardSoundCreate.class)
public interface SoundboardSounds extends Dispatch {

static ImmutableGuildSoundboardSoundCreate.Builder builder() {
return ImmutableGuildSoundboardSoundCreate.builder();
}

@JsonProperty("soundboard_sounds")
List<SoundboardSoundData> soundboardSounds();

@JsonProperty("guild_id")
Id guildId();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package discord4j.discordjson.json.gateway;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import discord4j.discordjson.json.EmojiData;
import discord4j.discordjson.possible.Possible;
import java.util.Optional;
import javax.annotation.Nullable;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableVoiceChannelEffectSend.class)
@JsonDeserialize(as = ImmutableVoiceChannelEffectSend.class)
public interface VoiceChannelEffectSend extends Dispatch {

static ImmutableVoiceChannelEffectSend.Builder builder() {
return ImmutableVoiceChannelEffectSend.builder();
}

@JsonProperty("channel_id")
Id channelId();

@JsonProperty("guild_id")
Id guildId();

@JsonProperty("user_id")
Id userId();

Possible<Optional<EmojiData>> emoji();

@JsonProperty("animation_type")
Possible<Optional<Integer>> animationType();

@JsonProperty("animation_id")
Possible<Integer> animationId();

@JsonProperty("sound_id")
Possible<Integer> soundId();

@JsonProperty("sound_volume")
Possible<Double> soundVolume();

}
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,10 @@ public void readGuildScheduledEvents() throws IOException {
GuildScheduledEventData[] data = read("/rest/GuildScheduledEventData.json", GuildScheduledEventData[].class);
log.info("{}", Arrays.asList(data));
}

@Test
public void readSoundboardSoundData() throws IOException {
SoundboardSoundData[] data = read("/rest/SoundboardSoundData.json", SoundboardSoundData[].class);
log.info("{}", Arrays.asList(data));
}
}
19 changes: 19 additions & 0 deletions src/test/resources/rest/SoundboardSoundData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"name": "Yay",
"sound_id": "1106714396018884649",
"volume": 1,
"emoji_id": "989193655938064464",
"emoji_name": null,
"guild_id": "613425648685547541",
"available": true
},
{
"name": "quack",
"sound_id": "1",
"volume": 1.0,
"emoji_id": null,
"emoji_name": "🦆",
"available": true
}
]