feat: list discord voice channel dynamic data
adds a helper function to provide dynamic data of voice and stage channels of a discord server
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
import listChannels from './list-channels';
|
import listChannels from './list-channels';
|
||||||
|
import listVoiceChannels from './list-voice-channels';
|
||||||
|
|
||||||
export default [listChannels];
|
export default [listChannels, listVoiceChannels];
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List voice channels',
|
||||||
|
key: 'listVoiceChannels',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const channels: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
error: IJSONObject | null;
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
error: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await $.http.get(
|
||||||
|
`/guilds/${$.auth.data.guildId}/channels`
|
||||||
|
);
|
||||||
|
|
||||||
|
channels.data = response.data
|
||||||
|
.filter((channel: IJSONObject) => {
|
||||||
|
// filter in voice and stage channels only
|
||||||
|
return channel.type === 2 || channel.type === 13;
|
||||||
|
})
|
||||||
|
.map((channel: IJSONObject) => {
|
||||||
|
return {
|
||||||
|
value: channel.id,
|
||||||
|
name: channel.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return channels;
|
||||||
|
},
|
||||||
|
};
|
Reference in New Issue
Block a user