Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/discordbotportaljp/dispander.rb
Discord Message URL Expander for discorb
https://github.com/discordbotportaljp/dispander.rb
discorb discord
Last synced: 29 days ago
JSON representation
Discord Message URL Expander for discorb
- Host: GitHub
- URL: https://github.com/discordbotportaljp/dispander.rb
- Owner: DiscordBotPortalJP
- License: mit
- Created: 2021-09-01T09:43:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-05T11:28:27.000Z (over 2 years ago)
- Last Synced: 2024-04-25T01:08:29.842Z (9 months ago)
- Topics: discorb, discord
- Language: Ruby
- Homepage: https://rubygems.org/gems/dispander.rb
- Size: 41 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.en.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# dispander.rb
An extension that adds message expanding feature for discorb bot.
![image](https://user-images.githubusercontent.com/59691627/131650571-ec50bf35-c971-4aeb-9a58-8fbf9b3e759b.png)Ruby version of [DiscordBotPortalJP/dispander](https://github.com/DiscordBotPortalJP/dispander).
## Install
Add this to Gemfile...
```ruby
gem 'dispander'
```And run this:
$ bundle install
Or...
$ gem install dispander
## Usage
### Load as Extension
```ruby
require "discorb"
require "discorb"
require "dispander"client = Discorb::Client.new
client.once :standby do
puts "Logged in as #{client.user}"
endclient.load_extension(Dispander::Core)
client.run ENV["DISCORD_BOT_TOKEN"]
```### Expand Manually
`Dispander::Core#dispand` to expand, `Dispander::Core#delete_message` to delete message.
```ruby
require "discorb"
require "dispander"client = Discorb::Client.new
dispander = Dispander::Core.new(client)
client.on :message do |message|
next if message.author.bot?dispander.dispand(message)
endclient.on :reaction_add do |event|
dispander.delete_message(event)
endclient.run ENV["DISCORD_BOT_TOKEN"]
```### Change emoji of deletion
Set emoji to `Dispander#delete_emoji`, or specify it in `Client#load_extension`.
```ruby
client.load_extension(Dispander::Core, delete_emoji: Discorb::UnicodeEmoji["x"])
```## Change the condition to expand
Override `Dispander#should_expand?`.
```ruby
dispander = Dispander::Core.new(client)def dispander.should_expand?(base_message, ids)
ENV["ALLOWED_GUILDS"].split(",").include?(ids[0])
endclient.load_extension(dispander)
```## License
Source is open under [MIT License](https://opensource.org/licenses/MIT).