use consistent guild getter syntax
This commit is contained in:
@@ -10,12 +10,9 @@ pub async fn ban(ctx: Context<'_>,
|
||||
#[rest]
|
||||
reason: Option<String>) -> Result<(), Error>
|
||||
{
|
||||
let guild = match ctx.guild_id() {
|
||||
Some(g) => g,
|
||||
None => {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if let Some(role) = settings::get_banrole(ctx, guild).await? {
|
||||
@@ -35,12 +32,9 @@ pub async fn ban(ctx: Context<'_>,
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
pub async fn unban(ctx: Context<'_>, user: serenity::User) -> Result<(), Error>
|
||||
{
|
||||
let guild = match ctx.guild_id() {
|
||||
Some(g) => g,
|
||||
None => {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if let Some(role) = settings::get_banrole(ctx, guild).await? {
|
||||
|
||||
@@ -73,10 +73,8 @@ pub async fn color(ctx: Context<'_>,
|
||||
Color::from_rgb(rgb.r, rgb.g, rgb.b)
|
||||
};
|
||||
|
||||
let guild = if let Some(guild) = ctx.guild_id() {
|
||||
guild
|
||||
} else {
|
||||
ctx.reply("This command can only be run inside of a guild.").await?;
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
||||
@@ -4,10 +4,8 @@ use crate::common::{Context, Error};
|
||||
/// Remove and delete your personal role
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
pub async fn disown(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let guild = if let Some(guild) = ctx.guild_id() {
|
||||
guild
|
||||
} else {
|
||||
ctx.reply("This command can only be run inside of a guild.").await?;
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
||||
@@ -6,13 +6,10 @@ use poise::serenity_prelude::EditRole;
|
||||
/// Change the name of your personal role
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
pub async fn name(ctx: Context<'_>, #[rest] name: String) -> Result<(), Error> {
|
||||
let guild = if let Some(guild) = ctx.guild_id() {
|
||||
guild
|
||||
} else {
|
||||
ctx.reply("This command can only be run inside of a guild.").await?;
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let user = ctx.author();
|
||||
|
||||
let mut tx = ctx.data().database.begin().await?;
|
||||
|
||||
@@ -6,10 +6,8 @@ use poise::serenity_prelude as serenity;
|
||||
/// Register an existing role as a user's custom role. This deletes their current self role.
|
||||
#[poise::command(slash_command, prefix_command, required_permissions = "MANAGE_ROLES")]
|
||||
pub async fn register(ctx: Context<'_>, user: serenity::User, role: serenity::Role) -> Result<(), Error> {
|
||||
let guild = if let Some(guild) = ctx.guild_id() {
|
||||
guild
|
||||
} else {
|
||||
ctx.reply("This command can only be run inside of a guild.").await?;
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
||||
@@ -5,10 +5,8 @@ use poise::serenity_prelude as serenity;
|
||||
|
||||
#[poise::command(slash_command, prefix_command, required_permissions = "MANAGE_ROLES")]
|
||||
pub async fn remove(ctx: Context<'_>, user: serenity::User) -> Result<(), Error> {
|
||||
let guild = if let Some(guild) = ctx.guild_id() {
|
||||
guild
|
||||
} else {
|
||||
ctx.reply("This command can only be run inside of a guild.").await?;
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
|
||||
@@ -20,12 +20,9 @@ async fn get_prefix(ctx: Context<'_>, guild: GuildId) -> Result<Option<String>,
|
||||
|
||||
#[poise::command(prefix_command, slash_command)]
|
||||
async fn prefix(ctx: Context<'_>, prefix: Option<String>) -> Result<(), Error> {
|
||||
let guild = match ctx.guild_id() {
|
||||
Some(g) => g,
|
||||
None => {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
match prefix {
|
||||
@@ -74,12 +71,9 @@ pub async fn get_positional_role(ctx: Context<'_>, guild: GuildId) -> Result<Opt
|
||||
|
||||
#[poise::command(prefix_command, slash_command)]
|
||||
pub async fn position(ctx: Context<'_>, role: Option<Role>) -> Result<(), Error> {
|
||||
let guild = match ctx.guild_id() {
|
||||
Some(g) => g,
|
||||
None => {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let member = ctx.author_member().await.unwrap();
|
||||
@@ -132,12 +126,9 @@ pub async fn get_hoist_selfroles(ctx: Context<'_>, guild: GuildId) -> Result<boo
|
||||
|
||||
#[poise::command(prefix_command, slash_command)]
|
||||
pub async fn hoist(ctx: Context<'_>, hoist: Option<bool>) -> Result<(), Error> {
|
||||
let guild = match ctx.guild_id() {
|
||||
Some(g) => g,
|
||||
None => {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
match hoist {
|
||||
@@ -195,12 +186,9 @@ pub async fn get_banrole(ctx: Context<'_>, guild: GuildId) -> Result<Option<Role
|
||||
|
||||
#[poise::command(prefix_command, slash_command)]
|
||||
pub async fn banrole(ctx: Context<'_>, role: Option<Role>) -> Result<(), Error> {
|
||||
let guild = match ctx.guild_id() {
|
||||
Some(g) => g,
|
||||
None => {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
let Some(guild) = ctx.guild_id() else {
|
||||
ctx.reply("This command must be ran within a guild.").await?;
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let member = ctx.author_member().await.unwrap();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use poise::serenity_prelude::GuildId;
|
||||
use poise::ReplyHandle;
|
||||
use sqlx::{Pool, Postgres};
|
||||
|
||||
|
||||
@@ -55,9 +55,8 @@ async fn event_handler(
|
||||
}
|
||||
|
||||
async fn get_prefix(ctx: PartialContext<'_, Data, Error>) -> Result<Option<String>, Error> {
|
||||
let guild = match ctx.guild_id {
|
||||
Some(guild) => guild,
|
||||
None => return Ok(ctx.data.prefix.clone()),
|
||||
let Some(guild) = ctx.guild_id else {
|
||||
return Ok(ctx.data.prefix.clone());
|
||||
};
|
||||
|
||||
let db = &ctx.data.database;
|
||||
|
||||
Reference in New Issue
Block a user