Since $bind is now in place (woohoo 🙌 ), areas in the code now require importing cache and getting the bounded channel (and sometimes prefix) in order to send a message to the desired channel. I think this should get abstracted out into a service!
Ideally this probably wants to look like:
(in services/discord_client.service.js)
// maybe there are imports here
class DiscordClientService{
constructor(...) {
this.cache = cache
this.discordClient = discordClient
}
// maybe some other functions here....
sendMessage(msg){
const boundChannel = this.cache.get('BIND', 'value');
this.discordClient.channels.cache.get(boundChannel).send(msg)
}
// and some other fns here...
}
That way, in commands/* and jobs/* we can simply use it by saying:
It'll help abstract out the implementation details of how a message should be sent out (which is nice because maybe it's something that wants to be different later on!) And it'll help with redundency - when a new job/service wants to send a message to channel, this.discordService.sendMessage is all that is needed now.
Since
$bind
is now in place (woohoo 🙌 ), areas in the code now require importingcache
and getting the bounded channel (and sometimes prefix) in order to send a message to the desired channel. I think this should get abstracted out into a service!Ideally this probably wants to look like: (in services/discord_client.service.js)
That way, in
commands/*
andjobs/*
we can simply use it by saying:It'll help abstract out the implementation details of how a message should be sent out (which is nice because maybe it's something that wants to be different later on!) And it'll help with redundency - when a new job/service wants to send a message to channel,
this.discordService.sendMessage
is all that is needed now.