mirror of
https://github.com/Dummi26/mcdcbot.git
synced 2025-03-10 05:13:53 +01:00
allow start/stop/run_command to only be used in the info channel (-> info channel permissions control who has MC admin)
This commit is contained in:
parent
b68361e9f5
commit
8693508435
@ -41,6 +41,13 @@ async fn start(
|
|||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
#[description = "Server's name (see /list)"] srv: String,
|
#[description = "Server's name (see /list)"] srv: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
{
|
||||||
|
let cid = ctx.data().settings.lock().await.channel_id_info;
|
||||||
|
if ctx.channel_id() != cid {
|
||||||
|
ctx.say(format!("This command can only be used in <#{cid}>.",))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
// find server by name
|
// find server by name
|
||||||
let servers_lock = ctx.data().servers.lock().await;
|
let servers_lock = ctx.data().servers.lock().await;
|
||||||
let mut matching_server = None;
|
let mut matching_server = None;
|
||||||
@ -111,6 +118,13 @@ async fn start(
|
|||||||
}
|
}
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
async fn stop(ctx: Context<'_>) -> Result<(), Error> {
|
async fn stop(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
{
|
||||||
|
let cid = ctx.data().settings.lock().await.channel_id_info;
|
||||||
|
if ctx.channel_id() != cid {
|
||||||
|
ctx.say(format!("This command can only be used in <#{cid}>.",))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
let current_lock = ctx.data().current.lock().await;
|
let current_lock = ctx.data().current.lock().await;
|
||||||
if let Some((_, thread)) = current_lock.as_ref() {
|
if let Some((_, thread)) = current_lock.as_ref() {
|
||||||
_ = thread
|
_ = thread
|
||||||
@ -132,6 +146,13 @@ async fn run_command(
|
|||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
#[description = "command (without '/')"] cmd: String,
|
#[description = "command (without '/')"] cmd: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
{
|
||||||
|
let cid = ctx.data().settings.lock().await.channel_id_info;
|
||||||
|
if ctx.channel_id() != cid {
|
||||||
|
ctx.say(format!("This command can only be used in <#{cid}>.",))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
let current_lock = ctx.data().current.lock().await;
|
let current_lock = ctx.data().current.lock().await;
|
||||||
if let Some((_, thread)) = current_lock.as_ref() {
|
if let Some((_, thread)) = current_lock.as_ref() {
|
||||||
ctx.say(format!("Running '{cmd}'")).await?;
|
ctx.say(format!("Running '{cmd}'")).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user