Skip to content

Commit

Permalink
discord: commands > add legacy conenctions to 'conf channel'
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin committed Mar 3, 2024
1 parent c000bd3 commit bfee28e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Discord/Commands/Conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class ConfCommand extends Command {

const channelConf = await Channel.findOrCreate(interaction.channel, [
'connections',
'repos',
'orgs',
]);
const serverConf = await Guild.findOrCreate(interaction.guild);

Expand Down Expand Up @@ -172,6 +174,11 @@ class ConfCommand extends Command {
value: this.format(conf.getConnections()),
inline: true,
},
{
name: 'Legacy Connections',
value: this.format(conf.getLegacyConnections()),
inline: true,
},
{
name: 'Repo (repo)',
value: this.format(conf.get('repo')),
Expand Down
21 changes: 21 additions & 0 deletions lib/Models/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,31 @@ const Channel = bookshelf.Model.extend(
return this.hasMany('ChannelConnection');
},

/**
* @deprecated LEGACY
*/
repos() {
return this.hasMany('LegacyChannelRepo');
},

/**
* @deprecated LEGACY
*/
orgs() {
return this.hasMany('LegacyChannelOrg');
},

getConnections() {
return this.related('connections').pluck('githubName');
},

getLegacyConnections() {
return [
...this.related('orgs').pluck('name'),
...this.related('repos').pluck('name'),
];
},

async getSecret() {
const secret = this.get('secret');

Expand Down

0 comments on commit bfee28e

Please sign in to comment.