Is there anyway to see if a user has permission to run a command without using discord.ext. The code I made was this:
from time import gmtime, strftime
import discord
lockedChannelName = ""
lockedChannel = 0
lockedTime = ""
locker = ""
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
global lockedChannelName
global lockedChannel
global lockedTime
global locker
if message.content == "!lockbothere":
lockedTime = strftime("%H:%M:%S", gmtime())
lockedChannel = message.channel.id
lockedChannelName = message.channel.name
locker = message.author.name
if message.content == "!unlock":
lockedChannel = 0
file = open("logs.txt", "a", encoding="utf-8")
if message.author != self.user and True if lockedChannel == message.channel.id or lockedChannel == 0 else False:
file.write(str(message.author) + ": " + message.content + "\n\n")
file.close()
if message.content == "!logs":
file = open("logs.txt", encoding="utf-8")
if message.channel.id != lockedChannel and lockedChannel != 0:
await message.channel.send("Note: The logs were locked by " + locker + ". The text channel that was locked was " + lockedChannelName + ", it was locked at " + lockedTime + " GMT")
if lockedChannel != 0:
embed = discord.Embed(title="Logs in this channel", description="All Messages In " + lockedChannelName)
else:
embed = discord.Embed(title="Logs in this channel", description="All Messages In This Channel")
embed.add_field(name='The Logs!', value=file.read())
await message.channel.send(content=None, embed=embed)
file.close()
if message.content == "!clearlogs":
with open("logs.txt", "w", encoding="utf-8"):
pass
await message.channel.send("Succsessfully Deleted Logs")
bot = MyClient()
bot.run("lol nope")
What I am going for is to make !clearlogs, !lockbothere, and !unlock only available to admins.