Last active
March 26, 2024 10:30
-
-
Save Skarlett/1c9a746ccf668c2bd30cfc0b4903127b to your computer and use it in GitHub Desktop.
rust self bot using serenity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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