Skip to content

Commit

Permalink
add feature to give roles on adding reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivinjabraham committed Oct 15, 2024
1 parent a5ba711 commit 3ec1b48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::Context;
use crate::Data;
use crate::Error;
use crate::Context;

#[poise::command(prefix_command)]
async fn amdctl(ctx: Context<'_>) -> Result<(), Error> {
Expand Down
13 changes: 8 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Data {
reaction_roles: HashMap<MessageId, (ReactionType, RoleId)>,
}

const ARCHIVE_MESSAGE_ID: u64 = 1295815208689733703;
const ARCHIVE_MESSAGE_ID: u64 = 1295821555586175083;
const ARCHIVE_ROLE_ID: u64 = 1208457364274028574;

#[shuttle_runtime::main]
Expand Down Expand Up @@ -110,7 +110,9 @@ async fn event_handler(
if let Ok(member) =
guild_id.member(ctx, add_reaction.user_id.unwrap()).await
{
let _ = member.add_role(&ctx.http, *role_id).await;
if let Err(e) = member.add_role(&ctx.http, *role_id).await {
eprintln!("Error: {:?}", e);
}
}
}
}
Expand All @@ -124,10 +126,11 @@ async fn event_handler(
if &removed_reaction.emoji == expected_reaction {
if let Some(guild_id) = removed_reaction.guild_id {
if let Ok(member) = guild_id
.member(ctx, removed_reaction.user_id.unwrap())
.await
.member(ctx, removed_reaction.user_id.unwrap()).await
{
let _ = member.remove_role(&ctx.http, *role_id).await;
if let Err(e) = member.remove_role(&ctx.http, *role_id).await {
eprintln!("Error: {:?}", e);
}
}
}
}
Expand Down

0 comments on commit 3ec1b48

Please sign in to comment.