Skip to content

Instantly share code, notes, and snippets.

@Skarlett
Last active March 26, 2024 10:30
Show Gist options
  • Save Skarlett/1c9a746ccf668c2bd30cfc0b4903127b to your computer and use it in GitHub Desktop.
Save Skarlett/1c9a746ccf668c2bd30cfc0b4903127b to your computer and use it in GitHub Desktop.
rust self bot using serenity
/*
** Self bot usage for serenity.
** Avoid API calls which handle
** guild invitation or require guild intent
**
** These tend to be where the alarms are set.
** Avoid prefixed commands & instant replies.
**
*/
use serenity::prelude::*;
use serenity::async_trait;
use serenity::model::Message;
struct EvHandler;
impl EventHandler for EvHandler {
/* on_ready doesn't work. */
/* on_message */
async fn message(&self, ctx: Context, ev: Message)
{
println!("{}:{}", message.author.name, message.content);
if ev.content.starts_with("!AAAA") {
ev.channel_id.say(&ctx.http, "AAAA!").await;
}
}
}
#[tokio::main]
async fn main() {
/*
** Fill in your user token.
** obtain via js: console.log(w.localStorage.token)
** Or search for "Authenication" HTTP header
*/
let user_token = "";
let self_bot = Client::builder(user_token)
.event_handler(EvHandler)
.await
.expect("Error creating client");
if let Err(why) = self_bot.start().await {
eprintln!("Error: {:?}", why);
}
}
@Skarlett
Copy link
Author

It is also worth noting that discord does allow for self bots, but registered under this.

https://discord.com/developers/docs/change-log#userinstallable-apps-preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment