Hey Everyone! As usual you can find the previous relevant post below :)
So assuming you read that...here we go!
For our final class assignment in OSD600 (Open Source Development) we must either implement a new feature or fix a family of bugs in a repo we previously worked on. I opted to go with implementing a new feature.
So in Parrot currently anyone can use a command such as
!play <song> to or
!shuffle which shuffles the songs currently in
queue. This issue aims to add a feature where a user can only successfully call commands that modify the queue if they have a DJ Role. This would mean that non harmful commands such as
!now_playing which just returns what is currently playing are fine to be used by anyone on the discord server.
Honestly I had to rack my brain for a looooong time thinking about this one....I delved into Serenity.rs Docs for hours. FYI Serenity is a library for the discord API written in Rust and is used in Parrot.
After many hours I've come up with a plan. Each discord server is represented as a
Guild struct in serenity. It contains may fields such as
name but most importantly
roles which is a
HashMap<RoleId, Role> with
Role being a struct containing more info about that role such as
id. The docs for a
Guild is here and
So with this information what can we do? Well now all I have to do is find a way to check if the DJ role is in the server via the
Guild struct and then check is the user has said
role which can be done via the
has_role method on the
User struct. The docs on the
User struct is here
Well now all I have to do is code! The next blog will be an update which will hopefully be all the coding finished and then finally my overall thoughts in a final blog :) See ya!