mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-22 05:23:48 +00:00
Fix typings
This commit is contained in:
parent
a1403d7047
commit
973cd00c82
@ -76,7 +76,7 @@ export default class Datastore {
|
||||
return this.map.get(id);
|
||||
}
|
||||
|
||||
updateEntry(guild: Guild | { id: string, name: string }, newData: datastore) {
|
||||
updateEntry(guild: Guild | { id: string, name?: string }, newData: datastore) {
|
||||
newData.guild.name = guild.name;
|
||||
|
||||
let date = new Date();
|
||||
|
@ -1,20 +1,20 @@
|
||||
import { Collection, GuildMember, Message, OAuth2Guild, TextBasedChannel, VoiceBasedChannel, VoiceChannel } from "discord.js";
|
||||
import { getVoiceConnection, joinVoiceChannel, VoiceConnection } from "@discordjs/voice";
|
||||
import { Collection, GuildMember, Message, Guild, OAuth2Guild, TextBasedChannel, VoiceBasedChannel, VoiceChannel } from "discord.js";
|
||||
import { DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel, VoiceConnection } from "@discordjs/voice";
|
||||
import RadioClient from "../../Client";
|
||||
import { station } from "./Stations";
|
||||
import { datastore } from "./Datastore";
|
||||
|
||||
export interface radio {
|
||||
textChannel: TextBasedChannel | undefined | null,
|
||||
voiceChannel: VoiceBasedChannel | undefined,
|
||||
connection: VoiceConnection | null,
|
||||
textChannel: TextBasedChannel | null,
|
||||
voiceChannel: VoiceBasedChannel | null,
|
||||
connection: VoiceConnection | undefined,
|
||||
message: Message | null,
|
||||
station: station,
|
||||
datastore?: datastore,
|
||||
currentTime?: number,
|
||||
startTime: number,
|
||||
playTime?: number,
|
||||
guild?: any
|
||||
guild?: Guild | { id: string, name?: string }
|
||||
}
|
||||
|
||||
export interface state {
|
||||
@ -78,10 +78,11 @@ export default class Radio extends Map<string, radio> {
|
||||
const construct: radio = {
|
||||
textChannel: client.channels.cache.get(state.channels.text) as TextBasedChannel,
|
||||
voiceChannel: client.channels.cache.get(state.channels.voice) as VoiceBasedChannel,
|
||||
connection: null,
|
||||
connection: undefined,
|
||||
message: null,
|
||||
station: station,
|
||||
startTime: date.getTime()
|
||||
startTime: date.getTime(),
|
||||
guild: guild
|
||||
};
|
||||
this.set(guild.id, construct);
|
||||
|
||||
@ -91,7 +92,7 @@ export default class Radio extends Map<string, radio> {
|
||||
joinVoiceChannel({
|
||||
channelId: voiceChannel.id,
|
||||
guildId: voiceChannel.guild.id,
|
||||
adapterCreator: voiceChannel.guild.voiceAdapterCreator
|
||||
adapterCreator: voiceChannel.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator
|
||||
});
|
||||
|
||||
construct.connection = connection;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Guild } from "discord.js";
|
||||
import { Guild, OAuth2Guild } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
import { radio } from "./Radio";
|
||||
|
||||
@ -18,7 +18,7 @@ export default class Statistics {
|
||||
this.map = new Map();
|
||||
}
|
||||
|
||||
update(client: RadioClient, guild: Guild | null, radio: radio) {
|
||||
update(client: RadioClient, guild: Guild | { id: string, name?: string } | undefined, radio: radio) {
|
||||
if(!guild) return;
|
||||
|
||||
client.datastore?.checkEntry(guild.id);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ApplicationCommandOptionType, ChatInputCommandInteraction, GuildMember, PermissionFlagsBits, StringSelectMenuInteraction } from "discord.js";
|
||||
import { getVoiceConnection, joinVoiceChannel } from "@discordjs/voice";
|
||||
import { DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel } from "@discordjs/voice";
|
||||
import RadioClient from "../../Client";
|
||||
import { radio } from "../classes/Radio"
|
||||
|
||||
@ -129,10 +129,11 @@ export default {
|
||||
const construct: radio = {
|
||||
textChannel: interaction.channel,
|
||||
voiceChannel: voiceChannel,
|
||||
connection: null,
|
||||
connection: undefined,
|
||||
message: null,
|
||||
station: station,
|
||||
startTime: date.getTime()
|
||||
startTime: date.getTime(),
|
||||
guild: interaction.guild
|
||||
};
|
||||
client.radio?.set(interaction.guild?.id, construct);
|
||||
|
||||
@ -142,7 +143,7 @@ export default {
|
||||
joinVoiceChannel({
|
||||
channelId: voiceChannel.id,
|
||||
guildId: voiceChannel.guild.id,
|
||||
adapterCreator: voiceChannel.guild.voiceAdapterCreator
|
||||
adapterCreator: voiceChannel.guild?.voiceAdapterCreator as DiscordGatewayAdapterCreator
|
||||
});
|
||||
construct.connection = connection;
|
||||
let date = new Date();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ButtonInteraction, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||
import { ButtonInteraction, ChannelType, ChatInputCommandInteraction, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
import { command } from "../commands";
|
||||
|
||||
@ -11,6 +11,7 @@ export default {
|
||||
if(!interaction.guild) return;
|
||||
const radio = client.radio?.get(interaction.guild?.id);
|
||||
if(!radio) return;
|
||||
if(radio.textChannel?.type == ChannelType.DM || radio.textChannel?.type == ChannelType.GroupDM) return;
|
||||
client.statistics?.update(client, interaction.guild, radio);
|
||||
radio.connection?.destroy();
|
||||
client.funcs.logger('Radio', interaction.guild?.id + " / " + 'Stop');
|
||||
|
@ -3,16 +3,15 @@ import RadioClient from "../../Client";
|
||||
|
||||
export default function interactionCreate(client: RadioClient, interaction: Interaction) {
|
||||
if(!(interaction.isButton()) && !(interaction.isChatInputCommand()) && !(interaction.isStringSelectMenu())) return;
|
||||
if(interaction.channel?.type == ChannelType.DM || interaction.channel?.type == ChannelType.GroupDM) return;
|
||||
|
||||
if(interaction.channel?.type != ChannelType.DM){
|
||||
const permissions = interaction.channel?.permissionsFor(interaction.client.user);
|
||||
if (!permissions?.has(PermissionFlagsBits.ViewChannel)) return;
|
||||
const permissions = interaction.channel?.permissionsFor(interaction.client.user);
|
||||
if (!permissions?.has(PermissionFlagsBits.ViewChannel)) return;
|
||||
|
||||
if (!permissions?.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.noPermsEmbed,
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
if (!permissions?.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.noPermsEmbed,
|
||||
ephemeral: true
|
||||
});
|
||||
|
||||
if(interaction.isChatInputCommand()){
|
||||
const commandName = interaction.commandName;
|
||||
|
@ -1,9 +1,6 @@
|
||||
import { GuildMember, PermissionFlagsBits, VoiceState } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
const {
|
||||
getVoiceConnection,
|
||||
joinVoiceChannel
|
||||
} = require("@discordjs/voice");
|
||||
import { DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel } from "@discordjs/voice";
|
||||
|
||||
export default async function voiceStateUpdate(client: RadioClient, oldState: VoiceState, newState: VoiceState) {
|
||||
if (oldState.channel === null) return;
|
||||
@ -27,9 +24,9 @@ export default async function voiceStateUpdate(client: RadioClient, oldState: Vo
|
||||
setTimeout(
|
||||
async () => (
|
||||
radio.connection = joinVoiceChannel({
|
||||
channelId: oldState.channel?.id,
|
||||
guildId: oldState.channel?.guild.id,
|
||||
adapterCreator: oldState.channel?.guild.voiceAdapterCreator
|
||||
channelId: oldState.channel?.id as string,
|
||||
guildId: oldState.channel?.guild.id as string,
|
||||
adapterCreator: oldState.channel?.guild.voiceAdapterCreator as DiscordGatewayAdapterCreator
|
||||
})
|
||||
),
|
||||
1000
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, Guild, OAuth2Guild, StringSelectMenuInteraction } from "discord.js";
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, ChatInputCommandInteraction, EmbedBuilder, Guild, OAuth2Guild, StringSelectMenuInteraction } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
import { station } from "../classes/Stations";
|
||||
|
||||
@ -7,6 +7,7 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
||||
|
||||
const radio = client.radio?.get(guild.id);
|
||||
if(!radio) return;
|
||||
if(radio.textChannel?.type == ChannelType.DM || radio.textChannel?.type == ChannelType.GroupDM) return;
|
||||
const audioPlayer = client.streamer?.listen(station);
|
||||
if(!audioPlayer) return;
|
||||
radio.connection?.subscribe(audioPlayer);
|
||||
@ -123,7 +124,7 @@ export default async function play(client: RadioClient, interaction: ChatInputCo
|
||||
let timer : NodeJS.Timeout = setInterval(async function(){
|
||||
const radio = client.radio?.get(guild.id);
|
||||
|
||||
if(!radio || !oldRadio || radio.station.name != oldRadio.station.name) {
|
||||
if(!radio || !oldRadio || radio.station.name != oldRadio.station.name || radio.textChannel?.type == ChannelType.DM || radio.textChannel?.type == ChannelType.GroupDM) {
|
||||
return clearInterval(timer);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@ import { Guild } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
import { radio } from "../classes/Radio";
|
||||
|
||||
export default function saveState(client: RadioClient, guild: Guild, radio: radio){
|
||||
if(!client.datastore) return;
|
||||
export default function saveState(client: RadioClient, guild: Guild | { id: string, name?: string } | undefined, radio: radio){
|
||||
if(!client.datastore || !guild) return;
|
||||
client.datastore.checkEntry(guild.id);
|
||||
|
||||
let date = new Date();
|
||||
|
Loading…
Reference in New Issue
Block a user