feat: add dms, hieracthical arguments, permission and rank system
This commit is contained in:
parent
544bbf73cb
commit
257bc55b75
25 changed files with 503 additions and 209 deletions
|
|
@ -41,27 +41,40 @@ impl Command for BalanceCommand {
|
|||
arg_type: ArgumentType::String,
|
||||
required: false,
|
||||
default: None,
|
||||
children: &[],
|
||||
}]
|
||||
}
|
||||
async fn constructed(&mut self, _: Client) {}
|
||||
async fn event(&mut self, _: Client, _: ClientEvent) {}
|
||||
|
||||
async fn execute(&mut self, client: Client, player: Player, args: ParsedArguments) {
|
||||
let id = match args.get("user_id") {
|
||||
Some(ParsedArgument::String(s)) => s.as_str(),
|
||||
_ => player._id.as_str(),
|
||||
async fn execute(
|
||||
&mut self,
|
||||
client: Client,
|
||||
player: Player,
|
||||
args: ParsedArguments,
|
||||
command_user: User,
|
||||
) {
|
||||
let user = match args.get("user_id") {
|
||||
Some(ParsedArgument::String(s)) => {
|
||||
let id = s.as_str();
|
||||
sqlx::query_as::<_, User>("SELECT * FROM users WHERE _id = $1")
|
||||
.bind(id)
|
||||
.fetch_optional(self.pool.as_ref())
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
_ => Some(command_user),
|
||||
};
|
||||
|
||||
let user = sqlx::query_as::<_, User>("SELECT * FROM users WHERE _id = $1")
|
||||
.bind(id)
|
||||
.fetch_optional(self.pool.as_ref())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
match user {
|
||||
Some(user) => {
|
||||
let mut who: String = "You have".to_string();
|
||||
if user._id != player._id.as_str() {
|
||||
who = format!("{} has ", player._id);
|
||||
}
|
||||
|
||||
client
|
||||
.message(format!("You have {} coins.", user.balance))
|
||||
.message(format!("{} {} coins.", who, user.balance))
|
||||
.await;
|
||||
}
|
||||
None => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue