Looking for examples of sending messages without events
See original GitHub issueHi there, and thanks for the awesome library!
I was able to build the basic ping pong example within an hour, and everything works out of the gate. Great stuff. One thing that is stumping me, however, is that I am so far unable to just “send” a message without a particular event happening (not relying on the kord.on<> { }
extension function.
I’m building a bot that is basically an external sentinel to a service I built, and I’d like the bot to be able to send an alert in a particular channel for devs whenever my service is not available, or when certain thresholds internal to my service are met. In that way, I don’t want to bot to respond to any particular message, I need it to be able to send its own messages whenever it wants.
I have the proper snowflake for the guild and channel and I’m trying to play with the Channel
and MessageBehavior
objects, but so far I haven’t been able to make it work.
I’m wondering if you have simple examples of that somewhere, or if you could maybe add one to the wiki. Cheers!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I think I’m following you, but for some reason it’s not quite clicking yet. I’m also not trying to pre-build anything, I mostly just want to fire up the bot once an hour and for it to post in our channel if something is wrong.
You say
Do you mean by that that the message is posted in the channel (and then stored in the variable?). If that is the case the error is on my configuration, as the bot runs but doesn’t post anything at the moment, using the following:
Any idea where I might be going wrong?
EDIT: My problem was the
login()
. Got it working now. Cheers!Hello @thunderbiscuit,
You are not obliqued to send messages in events only. However, you need to get a MessageChannelBehavior at least. use our
getChannelOf<MessageChannelBehavior>
orgetChannelOrNull<MessageChannelBehavior>
on the Kord instancesame applies for a MessageBehavior you can use the
channelOf
function to switch the type of channel.TL;DR: You need MessageChannelBehavior at least to send a message.
Note: depending on the version
channelOf
forChannel
s may be calledof
in older versions