adding permission error
This commit is contained in:
21
test.py
21
test.py
@@ -6,6 +6,7 @@ import threading
|
||||
from os import walk, path, makedirs, remove, rename, listdir
|
||||
|
||||
import discord
|
||||
import dislash
|
||||
from discord.ext import commands
|
||||
from dislash import InteractionClient, Option, OptionType, OptionChoice
|
||||
|
||||
@@ -131,7 +132,7 @@ class Commands:
|
||||
@staticmethod
|
||||
async def set_prefix(ctx, prefix: str):
|
||||
await Commands.write_json(ctx.guild.id, "prefix", prefix)
|
||||
await ctx.send(f"Prefix set to: `{prefix}`")
|
||||
await ctx.send(f"Prefix set to: `{prefix}`", ephemeral=True)
|
||||
|
||||
@staticmethod
|
||||
def list_files(fold: str):
|
||||
@@ -150,12 +151,12 @@ class Commands:
|
||||
parameter = None
|
||||
try:
|
||||
with open('prefix.json', 'r', encoding='utf-8') as fp: # Open the JSON
|
||||
jsonObject = json.load(fp) # Load the custom prefixes
|
||||
_json = json.load(fp) # Load the custom prefixes
|
||||
except TypeError:
|
||||
jsonObject = {}
|
||||
_json = {}
|
||||
if guild: # If the guild exists
|
||||
try:
|
||||
guild_conf = jsonObject[f"{guild}"]
|
||||
guild_conf = _json[f"{guild}"]
|
||||
try:
|
||||
parameter = guild_conf[f"{param}"]
|
||||
except TypeError:
|
||||
@@ -306,11 +307,17 @@ async def command_set_prefix(ctx, prefix: str):
|
||||
Option("prefix", "Specify prefix", OptionType.STRING, required=True),
|
||||
]
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@dislash.has_permissions(administrator=True)
|
||||
async def slash_set_prefix(ctx, prefix: str):
|
||||
await Commands.set_prefix(ctx, prefix)
|
||||
|
||||
|
||||
@slash_set_prefix.error
|
||||
@command_set_prefix.error
|
||||
async def set_prefix_error(ctx):
|
||||
await ctx.reply('You don`t have permissions')
|
||||
|
||||
|
||||
@inter_client.slash_command(
|
||||
name="info",
|
||||
description="Read list of tracks for user",
|
||||
@@ -346,7 +353,7 @@ async def info(ctx, user=None):
|
||||
emb.add_field(name="Roles list", value=f"{roles}", inline=True)
|
||||
emb.set_footer(text="Information requested by: {}".format(ctx.author.display_name))
|
||||
|
||||
await ctx.reply(embed=emb)
|
||||
await ctx.reply(embed=emb, ephemeral=True)
|
||||
|
||||
|
||||
@inter_client.slash_command(
|
||||
@@ -376,7 +383,7 @@ async def set_bot_role(ctx, role):
|
||||
|
||||
|
||||
@inter_client.slash_command(
|
||||
name="cogs",
|
||||
name="cog",
|
||||
description="Work with cogs",
|
||||
options=[
|
||||
Option("what do",
|
||||
|
||||
Reference in New Issue
Block a user