Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(discord): add selector for channels in ui (#3731)
Also added partials and intents to properly cache channels
- Loading branch information
Showing
4 changed files
with
98 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
{ | ||
"settings": { | ||
"enabled": "Status", | ||
"listenAtChannels": { | ||
"title": "Listen at these channels (#name or id)", | ||
"help": "Separated by comma (,)" | ||
}, | ||
"sendOnlineAnnounceToChannel": "Send online announcement to this channel (#name or id)", | ||
"sendGeneralAnnounceToChannel": "Send general announcement to this channel (#name or id)", | ||
"listenAtChannels": "Listen for commands on this channel", | ||
"sendOnlineAnnounceToChannel": "Send online announcement to this channel", | ||
"sendGeneralAnnounceToChannel": "Send general announcement to this channel", | ||
"deleteMessagesAfterWhile": "Delete message after while", | ||
"clientId": "ClientId", | ||
"token": "Token", | ||
"joinToServerBtn": "Click to join bot to your server", | ||
"cannotJoinToServerBtn": "Set token and clientId to be able to join bot to your server" | ||
"cannotJoinToServerBtn": "Set token and clientId to be able to join bot to your server", | ||
"noChannelSelected": "no channel selected" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/panel/views/settings/components/interface/discord-channel.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<div class="d-flex"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text"> | ||
<template v-if="typeof translatedTitle === 'string'">{{ translatedTitle }}</template> | ||
<template v-else> | ||
{{ translatedTitle.title }} | ||
<small class="text-info" data-toggle="tooltip" data-html="true" :title="translatedTitle.help">[?]</small> | ||
</template> | ||
</span> | ||
</div> | ||
<b-form-select v-model="currentValue" :options="channels"></b-form-select> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Vue, Component, Prop, Watch } from 'vue-property-decorator'; | ||
import { getSocket } from 'src/panel/helpers/socket'; | ||
@Component({}) | ||
export default class discordChannel extends Vue { | ||
@Prop() readonly value: any; | ||
@Prop() readonly title: any; | ||
socket = getSocket('/integrations/discord') | ||
channels: { text: string, value: string }[] = [] | ||
currentValue = this.value; | ||
translatedTitle = this.translate(this.title); | ||
mounted() { | ||
this.socket.emit('discord::getChannels', (err, channels) => { | ||
console.groupCollapsed('discord::getChannels') | ||
console.log({channels}); | ||
console.groupEnd(); | ||
if (err) { | ||
return console.error(err); | ||
} | ||
// find channel in channels on current or unset current | ||
if (!channels.find(o => String(o.value) === String(this.currentValue))) { | ||
this.currentValue = ''; | ||
} | ||
this.channels = [{ value: '', text: `-- ${this.translate('integrations.discord.settings.noChannelSelected')} --` }, ...channels]; | ||
}); | ||
} | ||
@Watch('currentValue') | ||
onChange() { | ||
this.$emit('update', { value: this.currentValue }); | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters