Fix Issue with Help Command in Community-Discord-BOT

in #utopian-io6 years ago

Repository

https://github.com/discord-bot-tutorial/Community-Discord-BOT
Pull Request : https://github.com/discord-bot-tutorial/Community-Discord-BOT/pull/130

Project Info

A community-driven public Discord-BOT using C# and Discord .NET. The goal of this project is to create a solid general-purpose bot that can be easily extended and used in new and interesting ways.

Bug Fixes

Issue?

The help command of the bot was not checking the size of the embed. When the size reaches 6000 characters an exception is thrown and no help is sent as shown below https://github.com/discord-bot-tutorial/Community-Discord-BOT/issues/81

Solution?

After checking the code, all the help messages is adding as an Embed Field and when we are building the message the length of the message is going over 6000. At first I have taken a deep copy of the Embed Fields

var fields = builder.Fields.ToList();

Now checking if the embed length is over 6000. If it is more than 6000 removing the initial 10 fields from the embed. After removing fields again checking the length, if it is more just decreasing the initial count by 1 so that this time I will take one less than the previous one.

So when I am sending the message I am sending it for the first 10 fields only and the next message is sent for the remaining field.

GitHub Account

https://github.com/codingdefined

Sort:  

Thanks for the contribution, @codingdefined! A small, but relatively important change - great work! You explained the issue and solution succinctly, which made it very easy to review.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @amosbastian!

So far this week you've reviewed 2 contributions. Keep up the good work!

Hi @codingdefined!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @codingdefined!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 63814.67
ETH 3194.20
USDT 1.00
SBD 3.90