I’m doing a python ticket bot, but when I try to execute any command, they won’t work at all, and it would only send a console message saying
ERROR discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command “ticket” is not found
import discord
from discord.ext import commands
from utils.responses import get_response, load_faq
import sqlite3
conn = sqlite3.connect('user.db')
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS ticket
(id INTEGER PRIMARY KEY AUTOINCREMENT, discord_name TEXT, discord_id INTEGER, ticket_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP)""")
conn.commit()
class TicketCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.Cog.listener()
async def on_ready(self):
print(f'Bot Loaded | ticket_system.py ✅')
@commands.Cog.listener()
async def on_bot_shutdown():
cur.close()
conn.close()
@commands.command(name='ticket')
async def create_ticket(ctx):
guild = ctx.guild
category = discord.utils.get(guild.categories, id=int(ctx.bot.config['CATEGORY_ID']))
ticket_channel = await guild.create_text_channel(f'ticket-{ctx.author.name}', category=category)
await ticket_channel.set_permissions(ctx.author, read_messages=True, send_messages=True)
await ticket_channel.set_permissions(ctx.guild.default_role, read_messages=False, send_messages=False)
await ticket_channel.send(f'Hola {ctx.author.mention}, ¿en qué podemos ayudarte?')
@commands.command(name='close')
async def close_ticket(ctx):
if "ticket" in ctx.channel.name:
await ctx.channel.delete()
@commands.command(name='add')
async def add_user(ctx, member: discord.Member):
if "ticket" in ctx.channel.name:
await ctx.channel.set_permissions(member, read_messages=True, send_messages=True)
@commands.command(name='remove')
async def remove_user(ctx, member: discord.Member):
if "ticket" in ctx.channel.name:
await ctx.channel.set_permissions(member, read_messages=False, send_messages=False)
@commands.command(name='claim')
async def claim_ticket(ctx):
if "ticket" in ctx.channel.name:
await ctx.channel.send(f'{ctx.author.mention} ha reclamado este ticket.')
@commands.command(name='review')
async def review_ticket(ctx):
if "ticket" in ctx.channel.name:
await ctx.channel.send('Por favor califica el soporte recibido:n⭐⭐⭐⭐⭐')
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.bot.user:
return
if "ticket" in message.channel.name:
user_message = message.content
response = get_response(user_message)
await message.channel.send(response)
await self.bot.process_commands(message)
async def setup(bot):
await bot.add_cog(TicketCog(bot))
I just want to solve this problem
New contributor
felto feto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.