-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the ability to define a custom status for a bot
Possible for some time apparently (https://discord.com/developers/docs/change-log#aug-8-2023) However, a bot can only define customizable text, no emoji can be defined + Adds a test/example file for custom status display
- Loading branch information
Showing
2 changed files
with
58 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'discordrb' | ||
|
||
bot = Discordrb::Bot.new token: ENV.fetch('DISCORDRB_TOKEN') | ||
custom_status = ['Hello World!', '❤️ Love you', 'Finally custom status 🎉'] | ||
initialized = false | ||
thread = [] | ||
|
||
bot.ready do |_| | ||
next if initialized | ||
|
||
bot.game = 'game' | ||
sleep 5 | ||
|
||
bot.listening = 'music' | ||
sleep 5 | ||
|
||
bot.watching = 'you' | ||
sleep 5 | ||
|
||
bot.competing = 'mario kart' | ||
sleep 5 | ||
|
||
bot.stream('discordrb', 'https://twitch.tv/shardlab') | ||
sleep 5 | ||
|
||
initialized = true | ||
thread << Thread.new do | ||
loop do | ||
bot.custom_status = custom_status.first | ||
custom_status.rotate! | ||
|
||
sleep 5 | ||
end | ||
end | ||
end | ||
|
||
at_exit do | ||
thread.each(&:exit) | ||
bot.stop | ||
end | ||
|
||
bot.run |
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