├── token.json
├── bot.py
├── database.py
├── README.md
├── config.py
├── create.py
├── main.py
├── options.py
└── LICENSE
/token.json:
--------------------------------------------------------------------------------
1 | {"BotToken":"PLACETOKENHERE"}
--------------------------------------------------------------------------------
/bot.py:
--------------------------------------------------------------------------------
1 | import discord
2 | from discord.ext import commands
3 |
4 | intents = discord.Intents.all()
5 | bot = discord.Client(command_prefix=commands.when_mentioned_or('-'), intents=intents)
--------------------------------------------------------------------------------
/database.py:
--------------------------------------------------------------------------------
1 | import sqlite3
2 | from config import databaseName
3 |
4 | class TicketData():
5 |
6 | def connect():
7 | con = sqlite3.connect(f"./{databaseName}")
8 | return con
9 |
10 | def cursor(connection):
11 | cur = connection.cursor()
12 | return cur
13 |
14 | def createlayout(connection, cursor):
15 | cursor.execute("CREATE TABLE TicketData(ChannelID, AuthorID, Claimed, TimeCreated, Type, Status, MessageID)")
16 | connection.commit()
17 | TicketData.verifylayout(cursor)
18 |
19 | def verifylayout(cursor):
20 | res = cursor.execute("SELECT name FROM sqlite_master WHERE name='TicketData'")
21 | if res.fetchone() is None:
22 | return False
23 | else:
24 | return True
25 |
26 | def add(connection, cursor, ChannelID, AuthorID, TimeCreated, Type, Status, MessageID):
27 | cursor.execute(f"""
28 | INSERT INTO TicketData VALUES
29 | ('{ChannelID}', '{AuthorID}', 'No', '{TimeCreated}', '{Type}', '{Status}', '{MessageID}')
30 | """)
31 | connection.commit()
32 |
33 | def getall(cursor, list):
34 | for rows in cursor.execute("SELECT * FROM TicketData ORDER BY ChannelID"):
35 | list.append(rows)
36 | return list
37 |
38 |
39 | def find(cursor, ChannelID):
40 | for row in cursor.execute("SELECT * FROM TicketData ORDER BY ChannelID"):
41 | if row[0] == f"{ChannelID}":
42 | return row
43 | else:
44 | pass
45 | return None
46 |
47 | def edit(connection, cursor, row, Claimed, Status):
48 | TicketData.delete(connection, cursor, row[0])
49 | cursor.execute(f"INSERT INTO TicketData VALUES ('{row[0]}', '{row[1]}', '{Claimed}', '{row[3]}', '{row[4]}', '{Status}', '{row[6]}')")
50 | connection.commit()
51 |
52 | def delete(connection, cursor, ChannelID):
53 | try:
54 | sql_update_query = ("""DELETE from TicketData where ChannelID = ?""")
55 | cursor.execute(sql_update_query, (str(ChannelID),))
56 | connection.commit()
57 | except Exception as e:
58 | print(e)
59 |
60 | def close(connection):
61 | connection.close()
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Discord-TicketBot 📝
2 |
3 | - A discord bot that is designed to manage and create ticket channels on behalf of server members using the [Rapptz discord.py API](https://github.com/Rapptz/discord.py).
4 | - Compiled on Python 3.10.
5 | - Tested to work on both Windows and Linux (Python 3.8.1 or newer).
6 | - Optionally, you can run this [bot in a docker environment](https://github.com/WebTheDev/TicketBot/tree/docker).
7 |
8 | ---
9 | ### Screenshots
10 |
11 |


12 |
13 | ---
14 | ### Features
15 | - Slash Commands and Interactions
16 | - The ability to place Tickets in different categories depending on their status (Active, Onhold, Archived)
17 | - Claim, Rename, Add, or Remove members from a ticket channel
18 | - System-Logging
19 | - Embedded Ticket Transcription Logs (using [chat-exporter](https://pypi.org/project/chat-exporter/))
20 | - Customizable Embeds
21 | - Customizable Ticket Options that members can select while creating tickets
22 | - Complex ticket permission system that can be customized per ticket option
23 | - Embedded "Create a ticket" button
24 | - GUI-like Ticket Options menu
25 | - A **/create** command that staff can use to manually create tickets
26 | - Something else that I'm probably missing!
27 |
28 | ---
29 | ### [Python](https://www.python.org/downloads/) Packages Required (Install with [Pip](https://pip.pypa.io/en/stable/installing/)):
30 | - [Discord](https://pypi.org/project/discord.py/)
31 | - [chat-exporter](https://pypi.org/project/chat-exporter/)
32 |
33 | ---
34 | ### Setup
35 | - Place all bot related files into a seperate folder (this is **important** to do so, or else the python compiler will not be able to find the bot files necessary for the ticket bot to work)
36 | - Create three categories in the discord server that the bot will be running in labeled: Active, OnHold, and Archived (set permissions as needed).
37 | - Create a channel that the bot can use to send the "Create a ticket" embed.
38 | - Create a bot application at the [discord developer panel](https://discord.com/developers/applications) and enable all intents.
39 | - Add the bot to your discord server by generating a OAuth2 invite link for your application and make sure to enable **bot** and **apps.commands**. Then for the permissions, tick Administrator.
40 | - Copy your bot token from the [discord developer panel](https://discord.com/developers/applications) under the bot tab and add it to the "[token.json](https://github.com/WebTheDev/TicketBot/blob/main/token.json)" file.
41 | - Adjust the "[config.py](https://github.com/WebTheDev/TicketBot/blob/main/config.py)" file to your liking.
42 | - Run the "[main.py](https://github.com/WebTheDev/TicketBot/blob/main/main.py)" file in python and the bot should start up. The bot will be fully running once the "Bot is up and running" message is outputted to the console.
43 | - Run the **/sync** command in order to sync the bot's slash commands with discord.
44 | - **ON FIRST RUN, THE BOT WILL EXIT PYTHON AUTOMATICALLY IN ORDER TO SAVE THE MESSAGE ID OF THE "CREATE A TICKET" EMBED IN THE BOT'S CONFIG.** Simply restart the bot again in order to apply the necessary config changes.
45 |
46 | ---
47 | ### Support
48 | - Please open up a issue to report any bugs with the TicketBot.
49 |
50 | ---
51 | ### Known Errors
52 | - Interaction fail on unknown slash command. (There is no error handling in the API for this yet, therefore a interaction fail will occur on the users side and a compiler error will be outputted to the console)
53 | - Viewing Transcribed Tickets in a Web Browser, discord has restricted the ability to view sent files in a channel in a web browser. I am currently working on a fix to resolve this issue.
54 | ---
55 | ### Creators Note
56 | - This bot is protected and licensed under the GNU General Public License v3.0. I am not liable for any damage that my bots may cause to your computer or discord server. I have the right to deny support for my bots at anytime for any reason. Even though this bot is open-sourced, it's source-code may be used for inspiration but may not be used for malicious intent or commercial use.
57 |
58 | - This is the fourth iteration of this bot, all previous versions have been used in private closed environments and will not be released to the public. This is the first public version of this bot.
59 |
60 | - I would like to say a huge thanks to my good friend [Reb](https://rebsdesigns.com/). Without him, this whole idea of me making a "Ticket Bot" for discord would of never been possible. Thank you for giving me the opportunity to make a bot for you in the first place, kickstarting my devving career.
61 |
62 | - Thank you to my good friend [Jake](https://github.com/jfmcdavitt) who helped me setup some of the backend parts of the bot. Without him, I would still be pondering on how am I going to make some parts of this thing work.
63 |
--------------------------------------------------------------------------------
/config.py:
--------------------------------------------------------------------------------
1 | #--------Ticket-Bot Config File--------#
2 | #Created by WebTheDev#
3 |
4 | #PLACE THE TOKEN FOR THE BOT IN THE TOKEN.JSON FILE!!!!#
5 |
6 | import json
7 |
8 | #Main Config:#
9 | botStatusType = '' #Bot Status Type (Ex. Playing, Watching, Listening, or Streaming)
10 | botStatusMessage = '' #The message that is shown on the bots activity
11 | guildID = 0000000000000000 #ID of the Guild the the bot is running in
12 | ticketLogsChannelID = 00000000000000 #ID of the Channel to send system logs to
13 | ticketTranscriptChannelID = 0000000000000000000 #ID of the Channel to send ticket transcripts to
14 | databaseName = 'tickets.db' #Leave set to default value unless if you want to use a different database name
15 | debugLogSendID = 000000000000000 #ID of the Bot Owner to send debug information to
16 |
17 | #Ticket Creation/Options Config:#
18 | IDOfChannelToSendTicketCreationEmbed = 000000000000000 #ID of the Channel to send the Create a ticket embed to
19 | IDofMessageForTicketCreation = 00000000000000000 #This is auto-adjusted, leave set to 00000000000000000
20 | activeTicketsCategoryID = 000000000000000000000 #ID of the active tickets category
21 | onHoldTicketsCategoryID = 00000000000000 #ID of the onhold tickets category
22 | archivedTicketsCategoryID = 000000000000000000000 #ID of the archived tickets category
23 |
24 | OptionsDict = {
25 | "Option 1": ("Sales 💲", "sales", "Create a sales related ticket."), #This is the ticket options dictionary. It defines the different types of tickets that users can create.
26 | "Option 2": ("Support ❓", "support", "Create a support related ticket."), #A ticket option definition should look something like this:
27 | "Option 3": ("Report ✋", "staff", "Create a ticket to speak with a member of staff.") #"Option #": ("Title of Option", "Type of Option", "Description of Option")
28 | } #Add a comma after every option definition except for the last one.
29 | #If you only have one option then no comma is needed.
30 |
31 |
32 | channelPerms = { #This is the ticket channel perms dictionary.
33 | "sales": (000000000000000000000), #This dictionary defines what roles will have access to each type of Ticket Channel
34 | "support": (000000000000000000000 , 000000000000000000000), #Each type can support multiple role IDS
35 | "staff": (000000000000000000000 , 000000000000000000000) #Each entry into the definition should look something like this:
36 | } #"Type of Option":(ROLEID1, ROLEID2)
37 | #Add a comma after every option definition except for the last one.
38 | #If you only have one option then no comma is needed.
39 | #IMPORTANT: MAKE SURE THAT THE TYPE OF OPTION IS THE SAME AS THE TYPE OF OPTION THAT WAS
40 | #DEFINED IN THE TICKET OPTIONS DEFINITION
41 | #IF NOT, PERMISSIONS WILL NOT BE SET CORRECTLY AND THE BOT WILL NOT WORK RIGHT.
42 |
43 |
44 | ticketTypeAllowedToCreatePrivateChannels = "staff" #Set this to be the type of option (roles) as defined in the ticket channel perms dictionary that can use the /create command.
45 | multipleTicketsAllowed = False #Set this to True if you would like members to be able to have multiple tickets open at once (otherwise set to False).
46 | dmTicketCopies = True #Set this to True if you would like the bot to dm Ticket Creators transcript copies of their ticket.
47 |
48 |
49 | #Embed Config:#
50 | footerOfEmbeds = '' #Set a custom embed footer of all embedded messages here!
51 | embedColor = 0xffffff #Set a custom hex color code for all embeds! Make sure to keep the 0x!
52 |
53 |
54 | def get_token():
55 | tokenFile = open("./token.json") #This definition pulls the token from the token.json file
56 | data = json.loads(tokenFile.read()) #Make sure to put your token in the token.json file where it says "PLACETOKENHERE"!
57 | return (data['BotToken'])
58 |
59 |
60 | firstRun = True #This is auto-adjusted, leave set to True on first bot start (unless if you are upgrading to a newer version of the bot, then set to False)
61 |
62 |
63 |
64 | #Please create a new issue on github if you are having issues with using the bot or find any bugs!
--------------------------------------------------------------------------------
/create.py:
--------------------------------------------------------------------------------
1 | import discord
2 | import asyncio
3 | import sys
4 | from datetime import datetime
5 | from discord.utils import get
6 | from config import *
7 | from database import *
8 | from bot import *
9 | from options import *
10 |
11 | class TicketCreationMenu(discord.ui.Select):
12 |
13 | def __init__(self):
14 | def optionsList():
15 | listofOptions = list(OptionsDict.values())
16 | oList = []
17 | for presets in listofOptions:
18 | oList.append(discord.SelectOption(label=presets[0], value=presets[1], description=presets[2]))
19 | return oList
20 | super().__init__(placeholder="Select an option...", options=optionsList(), min_values=1, max_values=1)
21 |
22 | async def callback(self, interaction: discord.Interaction):
23 | author = interaction.user
24 | x[interaction.user.display_name] = f"{self.values[0]}"
25 | await interaction.response.send_modal(TicketCreationModal())
26 | embed2 = discord.Embed(description=f'You can only select an option once!', color=embedColor)
27 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
28 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
29 | await interaction.edit_original_response(embed=embed2, view=None)
30 |
31 |
32 | class TicketCreationMenuUI(discord.ui.View):
33 | def __init__(self):
34 | super().__init__()
35 | self.add_item(TicketCreationMenu())
36 |
37 | class embedButtons(discord.ui.View):
38 | @discord.ui.button(label="Close Ticket", emoji="📝", style=discord.ButtonStyle.red)
39 | async def closeTicket(self, interaction: discord.Interaction, button: discord.Button):
40 | tchannel = interaction.channel
41 | author = interaction.user
42 | guild = interaction.guild
43 | connection = TicketData.connect()
44 | cursor = TicketData.cursor(connection)
45 | ticketInfo = TicketData.find(cursor, tchannel.id)
46 | TicketData.close(connection)
47 | ltype = (ticketInfo[4])
48 | allowedAccess = False
49 | try:
50 | for allowedRoles in list(channelPerms[f"{ltype}"]):
51 | prole = discord.utils.get(guild.roles, id=allowedRoles)
52 | if prole in author.roles:
53 | allowedAccess = True
54 | else:
55 | pass
56 | except TypeError:
57 | prole = get(guild.roles, id=channelPerms[f"{ltype}"])
58 | if prole in author.roles:
59 | allowedAccess = True
60 | else:
61 | pass
62 | if (allowedAccess == True) or (f"{ticketInfo[1]}" == f"{author.id}"):
63 | embed6 = discord.Embed(description="Are you sure that you want to close this ticket? This will result in the ticket being deleted.", color=embedColor)
64 | embed6.set_author(name=f'{author}', icon_url=author.display_avatar)
65 | embed6.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
66 | try:
67 | await interaction.response.send_message(embed=embed6, view=yesOrNoOption(timeout=None), ephemeral=True)
68 | except discord.HTTPException:
69 | await interaction.response.send_message("Something weird happened here, try again.")
70 | else:
71 | embed5 = discord.Embed(description=f'''Only the author of the ticket can use this button!''', color=embedColor)
72 | embed5.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
73 | embed5.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
74 | try:
75 | await interaction.response.send_message(embed=embed5, ephemeral=True)
76 | except discord.HTTPException:
77 | await interaction.response.send_message(f'''**You can't use that command!****''')
78 |
79 | @discord.ui.button(label="Options", emoji="⚙️", style=discord.ButtonStyle.green)
80 | async def ticketOptions(self, interaction: discord.Interaction, button: discord.Button):
81 | try:
82 | guild = interaction.guild
83 | author = interaction.user
84 | roleList = []
85 | permissionGranted = False
86 | for roleids in channelPerms.values():
87 | roleList.append(roleids)
88 | for allowedRoles in roleList:
89 | arole = get(guild.roles, id=allowedRoles)
90 | if arole in author.roles:
91 | permissionGranted = True
92 | else:
93 | pass
94 | tchannel = interaction.channel
95 | if permissionGranted == True:
96 | connection = TicketData.connect()
97 | cursor = TicketData.cursor(connection)
98 | ticketInfo = TicketData.find(cursor, tchannel.id)
99 | TicketData.close(connection)
100 | if ticketInfo != None:
101 | acategory = discord.utils.get(guild.categories, id=archivedTicketsCategoryID)
102 | acategoryc = (50 - (len(acategory.channels)))
103 | if acategoryc == 0:
104 | acategoryc2 = str(f'{acategoryc} slots left (full)')
105 | elif acategoryc == 1:
106 | acategoryc2 = str(f'{acategoryc} slot left (almost full)')
107 | elif acategoryc <= 5:
108 | acategoryc2 = str(f'{acategoryc} slots left (almost full)')
109 | elif acategoryc >= 6:
110 | acategoryc2 = str(f'{acategoryc} slots left')
111 | text = str(f'''🚩- Claim a ticket\n\n👥- Add a member to the ticket\n\n👋- Remove a member from the ticket\n\n🟢- Mark a ticket as active\n\n✋- Mark a ticket as onhold\n\n📓- Rename a ticket channel\n\n🗄️- Place a ticket in the archives **({acategoryc2})**\n\n📝- Transcribe and delete a ticket ''')
112 | embed3 = discord.Embed(title='''**Ticket Options**''', description=f'{text}', color=embedColor)
113 | try:
114 | lauthor2 = (ticketInfo[1])
115 | lauthor3 = (int(lauthor2))
116 | lauthor4 = get(guild.members, id=lauthor3)
117 | if lauthor4 == None:
118 | lauthor5 = await bot.fetch_user(lauthor3)
119 | if lauthor5 == None:
120 | lauthor = str("N/A")
121 | else:
122 | lauthor = lauthor5
123 | else:
124 | lauthor = lauthor4
125 | except IndexError:
126 | lauthor = str("N/A")
127 | try:
128 | ltype = (ticketInfo[4])
129 | except IndexError:
130 | ltype = str("N/A")
131 | try:
132 | lcreation = (ticketInfo[3])
133 | except IndexError:
134 | lcreation = str("N/A")
135 | try:
136 | lstatus = (ticketInfo[5])
137 | except IndexError:
138 | lstatus = str("N/A")
139 | if (ticketInfo[2]) != "No":
140 | lcstatus = (ticketInfo[2])
141 | lcstatus2 = int(lcstatus)
142 | claimer = await bot.fetch_user(lcstatus2)
143 | cstatus = str(f"**Claimed** ({claimer.mention})")
144 | else:
145 | cstatus = str(f'**Not Claimed**')
146 | if lauthor == 'N/A':
147 | text2 = str(f'''**__Author:__** N/A\n**__Type:__** {ltype}\n**__Status:__** {lstatus}\n**__Creation Date/Time:__** {lcreation}\n**__Claim Status:__** {cstatus}''')
148 | else:
149 | text2 = str(f'''**__Author:__** {lauthor.mention}\n**__Type:__** {ltype}\n**__Status:__** {lstatus}\n**__Creation Date/Time:__** {lcreation}\n**__Claim Status:__** {cstatus}''')
150 | embed3.add_field(name="Ticket Infomation:", value=f"{text2}")
151 | embed3.set_author(name=f'{author}', icon_url=author.display_avatar)
152 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
153 | try:
154 | await interaction.response.send_message(embed=embed3, ephemeral=True, view=optionsMenu())
155 | except discord.HTTPException:
156 | await interaction.response.send_message("HTTP Error that I'm too lazy to type out. Try again.", ephemeral=True)
157 | else:
158 | embed5 = discord.Embed(description=f'''You can only use this command in a ticket channel!''', color=embedColor)
159 | embed5.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
160 | embed5.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
161 | try:
162 | await interaction.response.send_message(embed=embed5, ephemeral=True)
163 | except discord.HTTPException:
164 | await interaction.response.send_message(f'''**You can only use this command in a ticket channel!****''')
165 | else:
166 | embed5 = discord.Embed(description=f'''You can't use that command!''', color=embedColor)
167 | embed5.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
168 | embed5.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
169 | try:
170 | await interaction.response.send_message(embed=embed5, ephemeral=True)
171 | except discord.HTTPException:
172 | await interaction.response.send_message(f'''**You can't use that command!****''')
173 | except Exception as e:
174 | message2 = await interaction.response.send_message(f'A unknown error has occurred, a copy of the error has been sent to the developer ❌', ephemeral=True)
175 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
176 | await bot.change_presence(status=discord.Status.dnd, activity=activity1)
177 | web = bot.get_user(debugLogSendID)
178 | text = str('''Error on line {}'''.format(sys.exc_info()[-1].tb_lineno))
179 | embed = discord.Embed(title='commands.options function fail', description=f'{text}, {str(e)}', color=embedColor)
180 | try:
181 | await web.send(embed=embed)
182 | except discord.HTTPException:
183 | await web.send("commands.options function fail" + str(e))
184 | print(str(e))
185 |
186 | class TicketCreationModal(discord.ui.Modal, title=f"Create a ticket"):
187 | answer = discord.ui.TextInput(label='Please provide a brief Ticket Description...', style=discord.TextStyle.paragraph, required=True, max_length=128)
188 |
189 | async def on_submit(self, interaction: discord.Interaction):
190 | ticketType = (x.get(interaction.user.display_name))
191 | author = interaction.user
192 | ticketDescription = (self.children[0].value)
193 | guild = bot.get_guild(guildID)
194 | me = bot.get_user(bot.user.id)
195 | default_perms = {}
196 | default_perms[guild.default_role] = discord.PermissionOverwrite(read_messages=False)
197 | default_perms[me] = discord.PermissionOverwrite(read_messages=True, send_messages=True)
198 | default_perms[author] = discord.PermissionOverwrite(read_messages=True, send_messages=True)
199 | try:
200 | for allowedRoles in list(channelPerms[f"{ticketType}"]):
201 | prole = get(guild.roles, id=allowedRoles)
202 | default_perms[prole] = discord.PermissionOverwrite(read_messages=True, send_messages=True)
203 | except TypeError:
204 | prole = get(guild.roles, id=channelPerms[f"{ticketType}"])
205 | default_perms[prole] = discord.PermissionOverwrite(read_messages=True, send_messages=True)
206 | now = datetime.now().strftime("%m-%d-%Y, %H:%M:%S")
207 | category = discord.utils.get(guild.categories, id=activeTicketsCategoryID)
208 | tchannel = await guild.create_text_channel(name=f'{ticketType}-{author.display_name}', category=category, overwrites=default_perms, topic=f"Reason: {ticketDescription} | Created by: {author}")
209 | embed3 = discord.Embed(description=f'Your {ticketType} ticket has been created, {tchannel.mention}. A member of our team will be with you shortly.', color=embedColor)
210 | embed3.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
211 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
212 | try:
213 | await interaction.response.send_message(embed=embed3, ephemeral=True)
214 | except discord.HTTPException:
215 | await interaction.response.send_message(f'Your {ticketType} ticket has been created, {tchannel.mention}. A member of our team will be with you shortly.', ephemeral=True)
216 | messageString = ""
217 | try:
218 | for rolesToPing in list(channelPerms[f"{ticketType}"]):
219 | prole = get(guild.roles, id=rolesToPing)
220 | messageString = messageString + (f" {prole.mention}")
221 | await tchannel.send(messageString)
222 | except TypeError:
223 | prole = get(guild.roles, id=channelPerms[ticketType])
224 | await tchannel.send(f'{prole.mention}')
225 | embed1 = discord.Embed(title='Ticket Created', description=f'{author.mention} has created a new {ticketType} ticket', color=embedColor)
226 | embed1.add_field(name=f'Reason:', value=f'{ticketDescription}')
227 | try:
228 | embed1.set_thumbnail(url=f'{author.display_avatar}')
229 | except Exception:
230 | pass
231 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=bot.user.display_avatar)
232 | try:
233 | message2 = await tchannel.send(embed=embed1, view=embedButtons(timeout=None))
234 | except discord.HTTPException as y:
235 | message2 = await tchannel.send(f"Ticket Created by {author}, Reason: {ticketDescription}", view=embedButtons(timeout=None))
236 | await message2.pin()
237 | connection = TicketData.connect()
238 | cursor = TicketData.cursor(connection)
239 | TicketData.add(connection, cursor, tchannel.id, author.id, f"{now} UTC", ticketType, "Active", message2.id)
240 | TicketData.close(connection)
241 | embed2 = discord.Embed(title='Ticket Created', description=f'{author.mention} has created a new ticket', color=embedColor)
242 | embed2.add_field(name='Channel:', value=f'{tchannel.mention}', inline=False)
243 | embed2.add_field(name=f'Reason:', value=f'{ticketDescription}', inline=False)
244 | embed2.add_field(name='Type:', value=f'{ticketType}', inline=False)
245 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=bot.user.display_avatar)
246 | syslogc = await bot.fetch_channel(ticketLogsChannelID)
247 | try:
248 | message3 = await syslogc.send(embed=embed2)
249 | except discord.HTTPException:
250 | message3 = await syslogc.send(f"Ticket Created by {author}, Reason: {ticketDescription}")
251 | del x[interaction.user.display_name]
252 |
253 | class TicketCreation(discord.ui.View):
254 | @discord.ui.button(label="Create a new ticket", emoji="📩", style=discord.ButtonStyle.blurple)
255 | async def presscreate(self, interaction:discord.Interaction, button:discord.ui.button):
256 | author = interaction.user
257 | guild = interaction.guild
258 | if multipleTicketsAllowed == False:
259 | connection = TicketData.connect()
260 | cursor = TicketData.cursor(connection)
261 | allTickets = []
262 | allTickets = TicketData.getall(cursor, allTickets)
263 | alreadyOpened = False
264 | for tickets in allTickets:
265 | if (int(tickets[1])) == author.id:
266 | if (str(tickets[5])) != ("Archived") and (str(tickets[4])) != ticketTypeAllowedToCreatePrivateChannels:
267 | alreadyOpened = True
268 | activeChannel = int(tickets[0])
269 | break
270 | else:
271 | pass
272 | else:
273 | pass
274 | if alreadyOpened == True:
275 | achannel = get(guild.channels, id=activeChannel)
276 | embed2 = discord.Embed(description=f"You can't have more than one ticket open at a time! Please close your current ticket before opening a new one.", color=embedColor)
277 | embed2.add_field(name="**__Open Tickets:__**", value=f"{achannel.mention}")
278 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
279 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
280 | await interaction.response.send_message(embed=embed2, ephemeral=True)
281 | else:
282 | embed2 = discord.Embed(description=f'Hi there {author.name}! Please select a ticket option from the drop-down list below!', color=embedColor)
283 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
284 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
285 | await interaction.response.send_message(embed=embed2, view=TicketCreationMenuUI(), ephemeral=True)
286 | else:
287 | embed2 = discord.Embed(description=f'Hi there {author.name}! Please select a ticket option from the drop-down list below!', color=embedColor)
288 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
289 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
290 | await interaction.response.send_message(embed=embed2, view=TicketCreationMenuUI(), ephemeral=True)
291 |
292 | x = dict()
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | import discord, datetime
2 | import sys
3 | import os
4 | import fileinput
5 | from discord import app_commands
6 | from datetime import datetime
7 | from discord.utils import get
8 | from config import *
9 | from database import *
10 | from options import *
11 | from create import *
12 | from bot import *
13 |
14 | ticket = app_commands.CommandTree(bot)
15 |
16 | @bot.event
17 | async def on_ready():
18 | await bot.wait_until_ready()
19 | databasecon = TicketData.connect()
20 | databasecur = TicketData.cursor(databasecon)
21 | if TicketData.verifylayout(databasecur) == True:
22 | print ("------------------------------------")
23 | print("[MESSAGE]: Ticket Database found.")
24 | else:
25 | print ("------------------------------------------------------")
26 | print("[WARN]: Ticket Database not found. Creating Database...")
27 | TicketData.createlayout(databasecon, databasecur)
28 | print ("------------------------------------")
29 | print (f"Bot Name: {bot.user.name}#{bot.user.discriminator}")
30 | print (f"Bot ID: {bot.user.id}")
31 | print ("Discord Version: " + discord.__version__)
32 | print ("------------------------------------")
33 | if f'{botStatusType}' == 'Playing':
34 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
35 | await bot.change_presence(status=discord.Status.online, activity=activity1)
36 | elif f'{botStatusType}' == 'Streaming':
37 | activity1 = discord.Activity(type=discord.ActivityType.streaming, name=f'{botStatusMessage}')
38 | await bot.change_presence(status=discord.Status.online, activity=activity1)
39 | elif f'{botStatusType}' == 'Watching':
40 | activity1 = discord.Activity(type=discord.ActivityType.watching, name=f'{botStatusMessage}')
41 | await bot.change_presence(status=discord.Status.online, activity=activity1)
42 | elif f'{botStatusType}' == 'Listening':
43 | activity1 = discord.Activity(type=discord.ActivityType.listening, name=f'{botStatusMessage}')
44 | await bot.change_presence(status=discord.Status.online, activity=activity1)
45 | else:
46 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
47 | await bot.change_presence(status=discord.Status.online, activity=activity1)
48 | print('''[WARN]: You have incorrectly specified the bot's activity type, the default has been selected. ''')
49 | print("----------------------------------------------------")
50 | if firstRun == True:
51 | print("[MESSAGE]: First Run is set to true, syncing slash commands with discord and generating ticket creation embed...")
52 | print("--------------------------------------------------------------------------------")
53 | await ticket.sync()
54 | tchannel = bot.get_channel(IDOfChannelToSendTicketCreationEmbed)
55 | embed = discord.Embed(title='''**Create a ticket**''', description=f'Press the button below to create a ticket!', color=embedColor)
56 | embed.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
57 | nmessage = await tchannel.send(embed=embed, view=TicketCreation())
58 | try:
59 | for line in fileinput.input(("config.py"), encoding="utf8", inplace=1):
60 | if "IDofMessageForTicketCreation" in line:
61 | line = line.replace(line, f'IDofMessageForTicketCreation = {nmessage.id} #This variable was automatically adjusted.\n' )
62 | elif "firstRun" in line:
63 | line = line.replace(line, "firstRun = False #This variable was automatically adjusted.\n")
64 | sys.stdout.write(line)
65 | except Exception:
66 | for line in fileinput.input(("config.py"), inplace=1):
67 | if "IDofMessageForTicketCreation" in line:
68 | line = line.replace(line, f'IDofMessageForTicketCreation = {nmessage.id} #This variable was automatically adjusted.\n' )
69 | elif "firstRun" in line:
70 | line = line.replace(line, "firstRun = False #This variable was automatically adjusted.\n")
71 | sys.stdout.write(line)
72 | embed2 = discord.Embed(title='**__Embed Message ID Updated:__**', description=f'New Message ID is: `{nmessage.id}`\n **Please restart the bot if not restarted automatically**', color=embedColor)
73 | embed2.set_footer(text=f'{bot.user.name} | {bot.user.id}', icon_url=f'{bot.user.display_avatar}')
74 | developer = bot.get_user(debugLogSendID)
75 | try:
76 | await developer.send(embed=embed2)
77 | except discord.HTTPException:
78 | await developer.send(f"**__Embed Message ID Updated:__**\nNew Message ID is: `{nmessage.id}`\n **Please restart the bot if not restarted automatically**")
79 | await bot.close()
80 | print("[WARN]: Embed Message Generated! Please restart the bot if not restarted automatically.")
81 | print("--------------------------------------------------------------------------------")
82 | os.execv(sys.argv[0], sys.argv)
83 | else:
84 | allTickets = []
85 | allTickets = TicketData.getall(databasecur, allTickets)
86 | for tickets in allTickets:
87 | channelID = int(tickets[0])
88 | messageID = int(tickets[6])
89 | tchannel = bot.get_channel(channelID)
90 | if tchannel != None:
91 | tmessage = await tchannel.fetch_message(messageID)
92 | await tmessage.edit(view=embedButtons(timeout=None))
93 | else:
94 | pass
95 | embed = discord.Embed(title='''**Create a ticket**''', description=f'Press the button below to create a ticket!', color=embedColor)
96 | embed.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
97 | try:
98 | tchannel = bot.get_channel(IDOfChannelToSendTicketCreationEmbed)
99 | tmessage = await tchannel.fetch_message(IDofMessageForTicketCreation)
100 | await tmessage.edit(embed=embed, view=TicketCreation(timeout=None))
101 | print("[MESSAGE]: Relinked to Ticket Creation Embed, standing by for ticket creation...")
102 | print("---------------------------------------------------------------------------------")
103 | except Exception:
104 | print("[ERROR]: Embed Message not found! Creating a new embed message, please restart the bot if not restarted automatically")
105 | print("--------------------------------------------------------------------------------")
106 | nmessage = await tchannel.send(embed=embed, view=TicketCreation())
107 | try:
108 | for line in fileinput.input(("config.py"), encoding="utf8", inplace=1):
109 | if "IDofMessageForTicketCreation" in line:
110 | line = line.replace(line, f'IDofMessageForTicketCreation = {nmessage.id} #This variable was automatically adjusted.\n' )
111 | sys.stdout.write(line)
112 | except Exception:
113 | for line in fileinput.input(("config.py"), inplace=1):
114 | if "IDofMessageForTicketCreation" in line:
115 | line = line.replace(line, f'IDofMessageForTicketCreation = {nmessage.id} #This variable was automatically adjusted.\n' )
116 | sys.stdout.write(line)
117 | embed2 = discord.Embed(title='**__Embed Message ID Updated:__**', description=f'New Message ID is: `{nmessage.id}`\n **Please restart the bot if not restarted automatically**', color=embedColor)
118 | embed2.set_footer(text=f'{bot.user.name} | {bot.user.id}', icon_url=f'{bot.user.display_avatar}')
119 | developer = bot.get_user(debugLogSendID)
120 | try:
121 | await developer.send(embed=embed2)
122 | except discord.HTTPException:
123 | await developer.send(f"**__Embed Message ID Updated:__**\nNew Message ID is: `{nmessage.id}`\n **Please restart the bot if not restarted automatically**")
124 | await bot.close()
125 | os.execv(sys.argv[0], sys.argv)
126 | print("[MESSAGE]: Bot is up and running!")
127 | print("------------------------------------")
128 | TicketData.close(databasecon)
129 |
130 |
131 | @ticket.command(name = "sync", description="Syncs the Ticket Command Tree to Discord.")
132 | async def self(interaction: discord.Interaction):
133 | author = interaction.user
134 | if author.id == debugLogSendID:
135 | embed1 = discord.Embed(description=f'Syncing Commands to Discord...', color=embedColor)
136 | embed1.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
137 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
138 | await interaction.response.send_message(embed=embed1, ephemeral=True)
139 | try:
140 | await ticket.sync()
141 | embed2 = discord.Embed(description=f'Commands Synced...', color=embedColor)
142 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
143 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
144 | await interaction.edit_original_response(embed=embed2)
145 | except Exception as e:
146 | embed2 = discord.Embed(title="**__An Error Occured:__**", description=f'Error: {e}', color=embedColor)
147 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
148 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
149 | await interaction.edit_original_response(embed=embed2)
150 | else:
151 | pass
152 |
153 | @ticket.command(name = "create", description="Creates a private ticket channel")
154 | async def self(interaction: discord.Interaction, reason: str = 'Unspecified'):
155 | try:
156 | author = interaction.user
157 | guild = interaction.guild
158 | allowedAcess = False
159 | try:
160 | for allowedRoles in list(channelPerms[f"{ticketTypeAllowedToCreatePrivateChannels}"]):
161 | prole = discord.utils.get(guild.roles, id=allowedRoles)
162 | if prole in author.roles:
163 | allowedAcess = True
164 | else:
165 | pass
166 | except TypeError:
167 | prole = get(guild.roles, id=channelPerms[f"{ticketTypeAllowedToCreatePrivateChannels}"])
168 | if prole in author.roles:
169 | allowedAcess = True
170 | else:
171 | pass
172 | syslogc = discord.utils.get(guild.channels, id=ticketLogsChannelID)
173 | if allowedAcess == True:
174 | categoryn = activeTicketsCategoryID
175 | category = discord.utils.get(guild.categories, id=categoryn)
176 | overwrites = {
177 | guild.default_role: discord.PermissionOverwrite(read_messages=False),
178 | guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
179 | prole: discord.PermissionOverwrite(read_messages=True, send_messages=True)
180 | }
181 | nchannel = await guild.create_text_channel(f'private-{author.display_name}', category=category, overwrites=overwrites, topic=f'Reason: {reason} | Created by: {author}')
182 | embed3 = discord.Embed(description=f'Private Ticket Channel created: {nchannel.mention}', color=embedColor)
183 | embed3.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
184 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
185 | try:
186 | await interaction.response.send_message(embed=embed3, ephemeral=True)
187 | except discord.HTTPException:
188 | await interaction.response.send_message(f'Private Ticket Channel created: {nchannel.mention}. A member of our team will be with you shortly.', ephemeral=True)
189 | embed1 = discord.Embed(title='Ticket Created', description=f'{author.mention} has created a new private ticket', color=embedColor)
190 | embed1.add_field(name=f'Reason:', value=f'{reason}')
191 | try:
192 | embed1.set_thumbnail(url=f'{author.display_avatar}')
193 | except Exception:
194 | pass
195 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=bot.user.display_avatar)
196 | message10 = await nchannel.send(author.mention)
197 | await message10.delete()
198 | try:
199 | message3 = await nchannel.send(embed=embed1, view=embedButtons())
200 | except discord.HTTPException as y:
201 | message3 = await nchannel.send(f"Ticket Created by {author}, Reason: {reason}", view=embedButtons())
202 | await message3.pin()
203 | connection = TicketData.connect()
204 | cursor = TicketData.cursor(connection)
205 | now = datetime.now().strftime("%m-%d-%Y, %H:%M:%S")
206 | TicketData.add(connection, cursor, nchannel.id, author.id, f'{now} EST', ticketTypeAllowedToCreatePrivateChannels, "active", message3.id)
207 | TicketData.close(connection)
208 | embed2 = discord.Embed(title='Ticket Created', description=f'{author.mention} has created a new ticket', color=embedColor)
209 | embed2.add_field(name='Channel:', value=f'{nchannel.mention}', inline=False)
210 | embed2.add_field(name=f'Reason:', value=f'{reason}', inline=False)
211 | embed2.add_field(name='Type:', value='Private', inline=False)
212 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
213 | try:
214 | await syslogc.send(embed=embed2)
215 | except discord.HTTPException:
216 | await syslogc.send(f"Ticket Created by {author}, Reason: {reason}")
217 | else:
218 | embed5 = discord.Embed(description=f'''{author.mention}, you can't use that command! ❌''', color=embedColor)
219 | embed5.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
220 | embed5.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
221 | try:
222 | await interaction.response.send_message(embed=embed5, ephemeral=True)
223 | except discord.HTTPException:
224 | await interaction.response.send_message(f'''{author.mention}, **you can't use that command! ❌**''', ephemeral=True)
225 | except Exception as e:
226 | message2 = await interaction.response.send_message(f'A unknown error has occurred, a copy of the error has been sent to the bot owner ❌', ephemeral=True)
227 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
228 | await bot.change_presence(status=discord.Status.dnd, activity=activity1)
229 | web = bot.get_user(debugLogSendID)
230 | text = str('''Error on line {}'''.format(sys.exc_info()[-1].tb_lineno))
231 | embed = discord.Embed(title='commands.options function fail', description=f'{text}, {str(e)}', color=embedColor)
232 | try:
233 | await web.send(embed=embed)
234 | except discord.HTTPException:
235 | await web.send("commands.options function fail" + str(e))
236 | print(text)
237 |
238 | @ticket.command(name = "options", description="Displays the options for a ticket channel")
239 | async def options(interaction: discord.Interaction):
240 | try:
241 | guild = interaction.guild
242 | author = interaction.user
243 | tchannel = interaction.channel
244 | roleList = []
245 | permissionGranted = False
246 | for roleids in channelPerms.values():
247 | roleList.append(roleids)
248 | for allowedRoles in roleList:
249 | arole = get(guild.roles, id=allowedRoles)
250 | if arole in author.roles:
251 | permissionGranted = True
252 | else:
253 | pass
254 | if permissionGranted == True:
255 | connection = TicketData.connect()
256 | cursor = TicketData.cursor(connection)
257 | ticketInfo = TicketData.find(cursor, tchannel.id)
258 | TicketData.close(connection)
259 | if ticketInfo != None:
260 | acategory = discord.utils.get(guild.categories, id=archivedTicketsCategoryID)
261 | acategoryc = (50 - (len(acategory.channels)))
262 | if acategoryc == 0:
263 | acategoryc2 = str(f'{acategoryc} slots left (full)')
264 | elif acategoryc == 1:
265 | acategoryc2 = str(f'{acategoryc} slot left (almost full)')
266 | elif acategoryc <= 5:
267 | acategoryc2 = str(f'{acategoryc} slots left (almost full)')
268 | elif acategoryc >= 6:
269 | acategoryc2 = str(f'{acategoryc} slots left')
270 | text = str(f'''🚩- Claim a ticket\n\n👥- Add a member to the ticket\n\n👋- Remove a member from the ticket\n\n🟢- Mark a ticket as active\n\n✋- Mark a ticket as onhold\n\n📓- Rename a ticket channel\n\n🗄️- Place a ticket in the archives **({acategoryc2})**\n\n📝- Transcribe and delete a ticket ''')
271 | embed3 = discord.Embed(title='''**Ticket Options**''', description=f'{text}', color=embedColor)
272 | try:
273 | lauthor2 = (ticketInfo[1])
274 | lauthor3 = (int(lauthor2))
275 | lauthor4 = get(guild.members, id=lauthor3)
276 | if lauthor4 == None:
277 | lauthor5 = await bot.fetch_user(lauthor3)
278 | if lauthor5 == None:
279 | lauthor = str("N/A")
280 | else:
281 | lauthor = lauthor5
282 | else:
283 | lauthor = lauthor4
284 | except IndexError:
285 | lauthor = str("N/A")
286 | try:
287 | ltype = (ticketInfo[4])
288 | except IndexError:
289 | ltype = str("N/A")
290 | try:
291 | lcreation = (ticketInfo[3])
292 | except IndexError:
293 | lcreation = str("N/A")
294 | try:
295 | lstatus = (ticketInfo[5])
296 | except IndexError:
297 | lstatus = str("N/A")
298 | if (ticketInfo[2]) != "No":
299 | lcstatus = (ticketInfo[2])
300 | lcstatus2 = int(lcstatus)
301 | claimer = await bot.fetch_user(lcstatus2)
302 | cstatus = str(f"**Claimed** ({claimer.mention})")
303 | else:
304 | cstatus = str(f'**Not Claimed**')
305 | if lauthor == 'N/A':
306 | text2 = str(f'''**__Author:__** N/A\n**__Type:__** {ltype}\n**__Status:__** {lstatus}\n**__Creation Date/Time:__** {lcreation}\n**__Claim Status:__** {cstatus}''')
307 | else:
308 | text2 = str(f'''**__Author:__** {lauthor.mention}\n**__Type:__** {ltype}\n**__Status:__** {lstatus}\n**__Creation Date/Time:__** {lcreation}\n**__Claim Status:__** {cstatus}''')
309 | embed3.add_field(name="Ticket Infomation:", value=f"{text2}")
310 | embed3.set_author(name=f'{author}', icon_url=author.display_avatar)
311 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
312 | try:
313 | await interaction.response.send_message(embed=embed3, ephemeral=True, view=optionsMenu())
314 | except discord.HTTPException:
315 | await interaction.response.send_message("HTTP Error that I'm too lazy to type out. Try again.", ephemeral=True)
316 | else:
317 | embed5 = discord.Embed(description=f'''You can only use this command in a ticket channel!''', color=embedColor)
318 | embed5.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
319 | embed5.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
320 | try:
321 | await interaction.response.send_message(embed=embed5, ephemeral=True)
322 | except discord.HTTPException:
323 | await interaction.response.send_message(f'''**You can only use this command in a ticket channel!****''')
324 | else:
325 | embed5 = discord.Embed(description=f'''You can't use that command!''', color=embedColor)
326 | embed5.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
327 | embed5.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
328 | try:
329 | await interaction.response.send_message(embed=embed5, ephemeral=True)
330 | except discord.HTTPException:
331 | await interaction.response.send_message(f'''**You can't use that command!****''')
332 | except Exception as e:
333 | message2 = await interaction.response.send_message(f'A unknown error has occurred, a copy of the error has been sent to the bot owner ❌', ephemeral=True)
334 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
335 | await bot.change_presence(status=discord.Status.dnd, activity=activity1)
336 | web = bot.get_user(debugLogSendID)
337 | text = str('''Error on line {}'''.format(sys.exc_info()[-1].tb_lineno))
338 | embed = discord.Embed(title='commands.options function fail', description=f'{text}, {str(e)}', color=embedColor)
339 | try:
340 | await web.send(embed=embed)
341 | except discord.HTTPException:
342 | await web.send("commands.options function fail" + str(e))
343 | print(text)
344 |
345 |
346 | @ticket.command(name = "info", description="Shows information about the bot!")
347 | async def self(interaction:discord.Interaction):
348 | try:
349 | author = interaction.user
350 | guild = interaction.guild
351 | embed6 = discord.Embed(title='Information', description=f'''Hi there! I'm **{bot.user.name}**, a discord ticket system bot designed by WebTheDev on GitHub!''', color=embedColor)
352 | latency = bot.latency * 1000
353 | embed6.add_field(name="**__Latency__**", value=f"❤️: {latency:.2f}ms")
354 | botOwner = await bot.fetch_user(debugLogSendID)
355 | embed6.add_field(name="**__Bot Owner__**", value=f"{botOwner.mention}")
356 | embed6.add_field(name= "**__Version__**", value="`v4.3.6`")
357 | embed6.add_field(name="**__Github Repository__**", value="[Click Me!](https://github.com/WebTheDev/TicketBot)")
358 | botCreator = await bot.fetch_user(387002430602346499)
359 | embed6.add_field(name="**__Bot Creator__**", value=f"{botCreator}")
360 | embed6.add_field(name="**__Status__**", value=f"Everything is good ✅")
361 | embed6.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
362 | embed6.set_author(name=f'{author}', icon_url=author.display_avatar)
363 | try:
364 | await interaction.response.send_message(embed=embed6, ephemeral=True)
365 | except discord.HTTPException:
366 | await interaction.response.send_message("Something funny happened here, try again", ephemeral=True)
367 | except Exception as e:
368 | message2 = await interaction.response.send_message(f'A unknown error has occurred, a copy of the error has been sent to the bot owner ❌', ephemeral=True)
369 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
370 | await bot.change_presence(status=discord.Status.dnd, activity=activity1)
371 | web = bot.get_user(debugLogSendID)
372 | text = str('''Error on line {}'''.format(sys.exc_info()[-1].tb_lineno))
373 | embed = discord.Embed(title='commands.options function fail', description=f'{text}, {str(e)}', color=embedColor)
374 | try:
375 | await web.send(embed=embed)
376 | except discord.HTTPException:
377 | await web.send("commands.options function fail" + str(e))
378 | print(text)
379 |
380 |
381 | @ticket.command(name = "python", description="A easter egg command!")
382 | async def self(interaction:discord.Interaction):
383 | try:
384 | author = interaction.user
385 | guild = interaction.guild
386 | embed = discord.Embed(description=f"DON'T DO IT **{author.display_name}**!!", color=embedColor)
387 | embed.set_image(url="https://media.tenor.com/j9rUo2jsSbEAAAAC/do-not-run-python-python-computer.gif")
388 | embed.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.avatar}')
389 | embed.set_author(name=f'{author}', icon_url=author.avatar)
390 | try:
391 | await interaction.response.send_message(embed=embed, ephemeral=True)
392 | except discord.HTTPException:
393 | await interaction.response.send_message("https://media.tenor.com/j9rUo2jsSbEAAAAC/do-not-run-python-python-computer.gif", ephemeral=True)
394 | except Exception as e:
395 | message2 = await interaction.response.send_message(f'A unknown error has occurred, a copy of the error has been sent to the bot owner ❌', ephemeral=True)
396 | activity1 = discord.Activity(type=discord.ActivityType.playing, name=f'{botStatusMessage}')
397 | await bot.change_presence(status=discord.Status.dnd, activity=activity1)
398 | web = bot.get_user(debugLogSendID)
399 | text = str('''Error on line {}'''.format(sys.exc_info()[-1].tb_lineno))
400 | embed = discord.Embed(title='commands.python function fail', description=f'{text}, {str(e)}', color=embedColor)
401 | try:
402 | await web.send(embed=embed)
403 | except discord.HTTPException:
404 | await web.send("commands.python function fail" + str(e))
405 | print(text)
406 |
407 |
408 | try:
409 | bot.run(f"{get_token()}")
410 | except discord.errors.LoginFailure as e:
411 | print('Login Failed, ERROR 401 Unauthorized')
--------------------------------------------------------------------------------
/options.py:
--------------------------------------------------------------------------------
1 | import discord
2 | import asyncio
3 | import io
4 | import chat_exporter
5 | from discord.utils import get
6 | from config import *
7 | from database import *
8 | from bot import *
9 |
10 | class addMemberModal(discord.ui.Modal, title="Add a member"):
11 | answer = discord.ui.TextInput(label='Place Member ID here', style=discord.TextStyle.short, required=True, max_length=128)
12 |
13 | async def on_submit(self, interaction: discord.Interaction):
14 | tchannel = interaction.channel
15 | author = interaction.user
16 | guild = interaction.guild
17 | connection = TicketData.connect()
18 | cursor = TicketData.cursor(connection)
19 | ticketInfo = TicketData.find(cursor, tchannel.id)
20 | TicketData.close(connection)
21 | try:
22 | ltype = (ticketInfo[4])
23 | except IndexError:
24 | ltype = str("N/A")
25 |
26 | try:
27 | amember = discord.utils.get(guild.members, id=int(self.children[0].value))
28 | except Exception:
29 | amember = None
30 | if amember == None:
31 | embed = discord.Embed(description=f'''I couldn't find that member, are you sure that is a valid member id? This is what I got: {self.children[0].value}''', color=embedColor)
32 | embed.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
33 | embed.set_author(name=f'{author}', icon_url=author.display_avatar)
34 | try:
35 | await interaction.response.send_message(embed=embed, ephemeral=True)
36 | except discord.HTTPException:
37 | await interaction.response.send_message(f'''I couldn't find that member, are you sure that is a valid member id? This is what I got: {self.children[0].value}''', ephemeral=True)
38 | elif amember != None:
39 | allowedAccess = False
40 | try:
41 | for allowedRoles in list(channelPerms[f"{ltype}"]):
42 | prole = discord.utils.get(guild.roles, id=allowedRoles)
43 | if prole in amember.roles:
44 | allowedAccess = True
45 | break
46 | else:
47 | pass
48 | except TypeError:
49 | prole = get(guild.roles, id=channelPerms[f"{ltype}"])
50 | if prole in amember.roles:
51 | allowedAccess = True
52 | else:
53 | pass
54 | if (allowedAccess == True):
55 | embed2 = discord.Embed(description=f'''I can't add that member!''', color=embedColor)
56 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
57 | embed2.set_author(name=f'{author}', icon_url=author.display_avatar)
58 | try:
59 | await interaction.response.send_message(embed=embed2, ephemeral=True)
60 | except discord.HTTPException:
61 | await interaction.response.send_message(f'''I can't add that member!`''', ephemeral=True)
62 | else:
63 | await tchannel.set_permissions(amember, send_messages=True, read_messages=True)
64 | embed2 = discord.Embed(description=f'''Member added. ✅''', color=embedColor)
65 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
66 | embed2.set_author(name=f'{author}', icon_url=author.display_avatar)
67 | try:
68 | await interaction.response.send_message(embed=embed2, ephemeral=True)
69 | except discord.HTTPException:
70 | await interaction.response.send_message(f'''Member added. ✅''', ephemeral=True)
71 | embed3 = discord.Embed(title="**__Member Added__**", description=f'''{amember.mention} has been added to the ticket by {author.mention}''', color=embedColor)
72 | embed3.set_thumbnail(url=f'{amember.avatar}')
73 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
74 | try:
75 | await tchannel.send(embed=embed3)
76 | except discord.HTTPException:
77 | await tchannel.send(f'{amember.mention} **has been added to the ticket by {author.mention}**')
78 |
79 | class removeMemberModal(discord.ui.Modal, title="Remove a member"):
80 | answer = discord.ui.TextInput(label='Place Member ID here', style=discord.TextStyle.short, required=True, max_length=128)
81 |
82 | async def on_submit(self, interaction: discord.Interaction):
83 | tchannel = interaction.channel
84 | author = interaction.user
85 | guild = interaction.guild
86 | connection = TicketData.connect()
87 | cursor = TicketData.cursor(connection)
88 | ticketInfo = TicketData.find(cursor, tchannel.id)
89 | TicketData.close(connection)
90 | try:
91 | ltype = (ticketInfo[4])
92 | except IndexError:
93 | ltype = str("N/A")
94 |
95 | try:
96 | amember = discord.utils.get(guild.members, id=int(self.children[0].value))
97 | except Exception:
98 | amember = None
99 | if amember == None:
100 | embed = discord.Embed(description=f'''I couldn't find that member, are you sure that is a valid member id? This is what I got: {self.children[0].value}''', color=embedColor)
101 | embed.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
102 | embed.set_author(name=f'{author}', icon_url=author.display_avatar)
103 | try:
104 | await interaction.response.send_message(embed=embed, ephemeral=True)
105 | except discord.HTTPException:
106 | await interaction.response.send_message(f'''I couldn't find that member, are you sure that is a valid member id? This is what I got: {self.children[0].value}''', ephemeral=True)
107 | elif amember != None:
108 | allowedAccess = False
109 | try:
110 | for allowedRoles in list(channelPerms[f"{ltype}"]):
111 | prole = discord.utils.get(guild.roles, id=allowedRoles)
112 | if prole in amember.roles:
113 | allowedAccess = True
114 | break
115 | else:
116 | pass
117 | except TypeError:
118 | prole = get(guild.roles, id=channelPerms[f"{ltype}"])
119 | if prole in amember.roles:
120 | allowedAccess = True
121 | else:
122 | pass
123 | if (allowedAccess == True):
124 | embed2 = discord.Embed(description=f'''I can't remove that member!''', color=embedColor)
125 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
126 | embed2.set_author(name=f'{author}', icon_url=author.display_avatar)
127 | try:
128 | await interaction.response.send_message(embed=embed2, ephemeral=True)
129 | except discord.HTTPException:
130 | await interaction.response.send_message(f'''I can't remove that member!`''', ephemeral=True)
131 | else:
132 | await tchannel.set_permissions(amember, send_messages=False, read_messages=False)
133 | embed2 = discord.Embed(description=f'''Member removed. ✅''', color=embedColor)
134 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
135 | embed2.set_author(name=f'{author}', icon_url=author.display_avatar)
136 | try:
137 | await interaction.response.send_message(embed=embed2, ephemeral=True)
138 | except discord.HTTPException:
139 | await interaction.response.send_message(f'''Member removed. ✅''', ephemeral=True)
140 |
141 | class renameChannelModal(discord.ui.Modal, title="Rename a Ticket Channel"):
142 | answer = discord.ui.TextInput(label='Place new name of ticket channel here', style=discord.TextStyle.short, required=True, max_length=32)
143 | async def on_submit(self, interaction: discord.Interaction):
144 | tchannel = interaction.channel
145 | author = interaction.user
146 | if f"{self.children[0].value}" == '':
147 | embed4 = discord.Embed(description=f'''You didn't provide a valid answer! Please try again. I got {self.children[0].value}''', color=embedColor)
148 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
149 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
150 | try:
151 | await interaction.response.send_message(embed=embed4, ephemeral=True)
152 | except discord.HTTPException:
153 | await interaction.response.send_message(f'''You didn't provide a valid answer! Please try again. I got {self.children[0].value}''', ephemeral=True)
154 | else:
155 | embed2 = discord.Embed(description=f'Channel Renamed ✅', color=embedColor)
156 | embed2.set_author(name=f'{author}', icon_url=author.display_avatar)
157 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
158 | await tchannel.edit(name=self.children[0].value)
159 | await interaction.response.send_message(embed=embed2, ephemeral=True)
160 |
161 |
162 | class optionsMenu(discord.ui.View):
163 | @discord.ui.button(label="Claim this Ticket", emoji="🚩", style=discord.ButtonStyle.gray)
164 | async def claim(self, interaction:discord.Interaction, button: discord.Button):
165 | tchannel = interaction.channel
166 | author = interaction.user
167 | guild = interaction.guild
168 | connection = TicketData.connect()
169 | cursor = TicketData.cursor(connection)
170 | ticketInfo = TicketData.find(cursor, tchannel.id)
171 | syslogc = get(guild.channels, id=ticketLogsChannelID)
172 | if (ticketInfo[2]) != "No":
173 | embed1 = discord.Embed(description=f'This ticket has already been claimed!', color=embedColor)
174 | embed1.set_author(name=f'{author}', icon_url=author.display_avatar)
175 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
176 | try:
177 | await interaction.response.edit_message(embed=embed1, view=None)
178 | except discord.HTTPException:
179 | await interaction.response.edit_message(f"This ticket has already been claimed!", view=None)
180 | else:
181 | embed3 = discord.Embed(description=f'Ticket Claimed ✅', color=embedColor)
182 | embed3.set_author(name=f'{author}', icon_url=author.display_avatar)
183 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
184 | try:
185 | await interaction.response.edit_message(embed=embed3, view=None)
186 | except discord.HTTPException:
187 | await interaction.response.edit_message(f"Ticket Claimed ✅", view=None)
188 |
189 | embed2 = discord.Embed(title="**__Ticket Claimed__**", description=f'''{author.mention} has claimed this ticket.''', color=embedColor)
190 | embed2.set_author(name=f'{author}', icon_url=author.display_avatar)
191 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
192 | try:
193 | await tchannel.send(embed=embed2)
194 | except discord.HTTPException:
195 | await tchannel.send(f'''**__Ticket Claimed__**\n{author.mention} has claimed this ticket.''')
196 | TicketData.edit(connection, cursor, ticketInfo, author.id, ticketInfo[5])
197 | embed1 = discord.Embed(title='Ticket Claimed', description=f'{author.mention} has claimed ticket {tchannel.mention}', color=embedColor)
198 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
199 | try:
200 | message2 = await syslogc.send(embed=embed1)
201 | except discord.HTTPException:
202 | message2 = await syslogc.send(f"**{author.mention} has claimed ticket {tchannel.mention}**")
203 | else:
204 | pass
205 | TicketData.close(connection)
206 |
207 | @discord.ui.button(label="Add a member", emoji="👥", style=discord.ButtonStyle.green)
208 | async def addmember(self, interaction:discord.Interaction, button: discord.ui.button):
209 | await interaction.response.send_modal(addMemberModal())
210 | author = interaction.user
211 | embed2 = discord.Embed(description=f'You can only push a button once!', color=embedColor)
212 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
213 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
214 | await interaction.edit_original_response(embed=embed2, view=None)
215 |
216 | @discord.ui.button(label="Remove a member", emoji="👋", style=discord.ButtonStyle.red)
217 | async def removemember(self, interaction:discord.Interaction, button: discord.ui.button):
218 | await interaction.response.send_modal(removeMemberModal())
219 | author = interaction.user
220 | embed2 = discord.Embed(description=f'You can only push a button once!', color=embedColor)
221 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
222 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
223 | await interaction.edit_original_response(embed=embed2, view=None)
224 |
225 | @discord.ui.button(label="Active Ticket", emoji="🟢", style=discord.ButtonStyle.blurple)
226 | async def activeticket(self, interaction:discord.Interaction, button: discord.ui.button):
227 | tchannel = interaction.channel
228 | author = interaction.user
229 | guild = interaction.guild
230 | syslogc = get(guild.channels, id=ticketLogsChannelID)
231 | connection = TicketData.connect()
232 | cursor = TicketData.cursor(connection)
233 | ticketInfo = TicketData.find(cursor, tchannel.id)
234 | categoryn = activeTicketsCategoryID
235 | if tchannel.category_id != categoryn:
236 | embed4 = discord.Embed(description=f'Setting Ticket to `Active` status...', color=embedColor)
237 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
238 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
239 | try:
240 | message3 = await interaction.response.edit_message(embed=embed4, view=None)
241 | except discord.HTTPException:
242 | message3 = await interaction.response.edit_message(f"Setting Ticket to `Active` status...", view=None)
243 | category = discord.utils.get(guild.categories, id=categoryn)
244 | await tchannel.edit(category=category)
245 | TicketData.edit(connection, cursor, ticketInfo, ticketInfo[2], "Active")
246 | embed1 = discord.Embed(title='__**Ticket Status Changed**__', description=f'This ticket has been set to `Active` ✅', color=embedColor)
247 | embed1.set_author(name=f'{author}', icon_url=author.display_avatar)
248 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
249 | try:
250 | message3 = await tchannel.send(embed=embed1)
251 | except discord.HTTPException:
252 | message3 = await tchannel.send(f"**This ticket has been set to `Active` ✅**")
253 | embed2 = discord.Embed(title='Ticket set to Active', description=f'Ticket {tchannel.mention} has been set to `Active` by {author.mention}', color=embedColor)
254 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
255 | try:
256 | await syslogc.send(embed=embed2)
257 | except discord.HTTPException:
258 | await syslogc.send(f"Ticket {tchannel.mention} has been set to `Active` by {author.mention}")
259 | elif tchannel.category_id == categoryn:
260 | embed1 = discord.Embed(description=f'This ticket is already set to `Active`!', color=embedColor)
261 | embed1.set_author(name=f'{author}', icon_url=author.display_avatar)
262 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
263 | try:
264 | await interaction.response.edit_message(embed=embed1, view=None)
265 | except discord.HTTPException:
266 | await tchannel.send(f"This ticket is already set to `Active`!")
267 | TicketData.close(connection)
268 |
269 | @discord.ui.button(label="Onhold Ticket", emoji="✋", style=discord.ButtonStyle.blurple)
270 | async def onholdticket(self, interaction:discord.Interaction, button: discord.ui.button):
271 | tchannel = interaction.channel
272 | author = interaction.user
273 | guild = interaction.guild
274 | syslogc = get(guild.channels, id=ticketLogsChannelID)
275 | connection = TicketData.connect()
276 | cursor = TicketData.cursor(connection)
277 | ticketInfo = TicketData.find(cursor, tchannel.id)
278 | categoryn = onHoldTicketsCategoryID
279 | if tchannel.category_id != categoryn:
280 | embed4 = discord.Embed(description=f'Setting Ticket to `Onhold` status...', color=embedColor)
281 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
282 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
283 | try:
284 | message3 = await interaction.response.edit_message(embed=embed4, view=None)
285 | except discord.HTTPException:
286 | message3 = await interaction.response.edit_message(f"Setting Ticket to `Onhold` status...", view=None)
287 | category = discord.utils.get(guild.categories, id=categoryn)
288 | await tchannel.edit(category=category)
289 | TicketData.edit(connection, cursor, ticketInfo, ticketInfo[2], "Onhold")
290 | embed1 = discord.Embed(title='__**Ticket Status Changed**__', description=f'This ticket has been set to `Onhold` ✅', color=embedColor)
291 | embed1.set_author(name=f'{author}', icon_url=author.display_avatar)
292 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
293 | try:
294 | message3 = await tchannel.send(embed=embed1)
295 | except discord.HTTPException:
296 | message3 = await tchannel.send(f"**This ticket has been set to `Onhold` ✅**")
297 | embed2 = discord.Embed(title='Ticket set to Onhold', description=f'Ticket {tchannel.mention} has been set to `Onhold` by {author.mention}', color=embedColor)
298 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
299 | try:
300 | await syslogc.send(embed=embed2)
301 | except discord.HTTPException:
302 | await syslogc.send(f"Ticket {tchannel.mention} has been set to `Onhold` by {author.mention}")
303 | elif tchannel.category_id == categoryn:
304 | embed1 = discord.Embed(description=f'This ticket is already set to `Onhold`!', color=embedColor)
305 | embed1.set_author(name=f'{author}', icon_url=author.display_avatar)
306 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
307 | try:
308 | await interaction.response.edit_message(embed=embed1, view=None)
309 | except discord.HTTPException:
310 | await tchannel.send(f"This ticket is already set to `Onhold`!")
311 | TicketData.close(connection)
312 |
313 | @discord.ui.button(label="Rename Ticket", emoji="✏️", style=discord.ButtonStyle.gray)
314 | async def rename(self, interaction:discord.Interaction, button: discord.ui.button):
315 | await interaction.response.send_modal(renameChannelModal())
316 | author = interaction.user
317 | embed2 = discord.Embed(description=f'You can only select a button once!', color=embedColor)
318 | embed2.set_author(name=f'{author}', icon_url=f'{author.display_avatar}')
319 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
320 | await interaction.edit_original_response(embed=embed2, view=None)
321 |
322 | @discord.ui.button(label="Archive Ticket", emoji="🗄️", style=discord.ButtonStyle.blurple)
323 | async def archive(self, interaction:discord.Interaction, button: discord.ui.button):
324 | author = interaction.user
325 | embed6 = discord.Embed(description="Are you sure that you want to archive this ticket? This will result in the ticket being moved to the archived category and the ticket will no longer be managed by the ticketbot.", color=embedColor)
326 | embed6.set_author(name=f'{author}', icon_url=author.display_avatar)
327 | embed6.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
328 | try:
329 | await interaction.response.edit_message(embed=embed6, view=ticketArchiveyesOrNoOption(timeout=None))
330 | except discord.HTTPException:
331 | await interaction.response.edit_message(content="Something weird happened here, try again.")
332 |
333 | @discord.ui.button(label="Transcribe Ticket", emoji="📝", style=discord.ButtonStyle.red)
334 | async def transcribe(self, interaction:discord.Interaction, button: discord.ui.button):
335 | author = interaction.user
336 | embed6 = discord.Embed(description="Are you sure that you want to close this ticket? This will result in the ticket being deleted.", color=embedColor)
337 | embed6.set_author(name=f'{author}', icon_url=author.display_avatar)
338 | embed6.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
339 | try:
340 | await interaction.response.edit_message(embed=embed6, view=yesOrNoOption(timeout=None))
341 | except discord.HTTPException:
342 | await interaction.response.edit_message("Something weird happened here, try again.")
343 |
344 |
345 | class yesOrNoOption(discord.ui.View):
346 | @discord.ui.button(label="Yes", style=discord.ButtonStyle.green)
347 | async def yes(self, interaction:discord.Interaction, button: discord.ui.button):
348 | tchannel = interaction.channel
349 | lchannel = bot.get_channel(ticketTranscriptChannelID)
350 | author = interaction.user
351 | guild = interaction.guild
352 | connection = TicketData.connect()
353 | cursor = TicketData.cursor(connection)
354 | ticketInfo = TicketData.find(cursor, tchannel.id)
355 | syslogc = get(guild.channels, id=ticketLogsChannelID)
356 | embed4 = discord.Embed(description=f'Transcribing Ticket...', color=embedColor)
357 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
358 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
359 | try:
360 | await interaction.response.edit_message(embed=embed4, view=None)
361 | except discord.HTTPException:
362 | await interaction.response.edit_message(f"Transcribing Ticket...", )
363 | connection = TicketData.connect()
364 | cursor = TicketData.cursor(connection)
365 | embed3 = discord.Embed(title=f'Ticket Closed', description=f'{author.mention} has closed this ticket, it will be logged and deleted within 5 seconds.', color=embedColor)
366 | embed3.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
367 | try:
368 | await tchannel.send(embed=embed3)
369 | except discord.HTTPException:
370 | await tchannel.send(f"{author.mention} has closed this ticket, it will be logged and deleted within 5 seconds.")
371 | await asyncio.sleep(2)
372 | transcript = await chat_exporter.export(tchannel)
373 | transcript_file = discord.File(io.BytesIO(transcript.encode()),
374 | filename=f"transcript-{tchannel.name}_{tchannel.id}.html")
375 | transcript_message = await lchannel.send(file=transcript_file)
376 | tauthor = await bot.fetch_user(int(ticketInfo[1]))
377 | embed2 = discord.Embed(title=f'Ticket Transcribed', description=f'A open ticket has been marked as closed by {author.mention}, it has been logged and deleted.', color=embedColor)
378 | embed2.set_thumbnail(url="https://static-00.iconduck.com/assets.00/memo-emoji-1948x2048-bgnk0vsq.png")
379 | embed2.set_author(name=author, icon_url=author.display_avatar)
380 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
381 | embed2.add_field(name='**__Channel Name:__**', value=f'#{tchannel.name}', inline=True)
382 | embed2.add_field(name="**__Author:__**", value=f"{tauthor.mention}", inline=True)
383 | embed2.add_field(name="**__Type:__**", value=f"{ticketInfo[4]}", inline=True)
384 | if dmTicketCopies == True:
385 | try:
386 | transcript_file1 = discord.File(io.BytesIO(transcript.encode()),
387 | filename=f"transcript-{tchannel.name}_{tchannel.id}.html")
388 | transcript_message1 = await tauthor.send(file=transcript_file1)
389 | embed3 = discord.Embed(title="Ticket Copy", description=f"Hi {tauthor.mention}!\n Thank you for creating a ticket with us. Attached to this message is a copy of your ticket for your records.\n\nPlease note, any media sent in your ticket will not load in the copy after a couple of days.\n \n ", color=embedColor)
390 | embed3.add_field(name="**__Jump/Download Link:__**", value=f"{transcript_message1.jump_url}", inline=True)
391 | transcript_url1 = ("https://webthedev.me/ticketviewer/?url="+ transcript_message1.attachments[0].url)
392 | embed3.add_field(name="**__View Link:__**", value=f"[Click here!]({transcript_url1})", inline=True)
393 | embed3.set_thumbnail(url="https://static-00.iconduck.com/assets.00/memo-emoji-1948x2048-bgnk0vsq.png")
394 | try:
395 | await tauthor.send(embed=embed3)
396 | except discord.HTTPException:
397 | await tauthor.send(f"Hi {tauthor.mention}!\n Thank you for creating a ticket with us. Attached to this message is a copy of your ticket for your records.\nPlease note, any media sent in your ticket will not load in the copy after a couple of days.\n**__Jump/Download Link:__{transcript_message.jump_url}\n**__View Link:__**[Click here!]({transcript_url1})")
398 | embed2.add_field(name="**__Copy Status:__**", value="A copy of the ticket was successfully delivered to the ticket creator. ✅")
399 | except Exception:
400 | embed2.add_field(name="**__Copy Status:__**", value="The copy failed to be delivered to the ticket creator. This is most likely due to their dms being off. ❌")
401 | else:
402 | pass
403 | embed2.add_field(name="**__Time Created:__**", value=f"{ticketInfo[3]}", inline=False)
404 | embed2.add_field(name="**__Jump/Download Link:__**", value=f"\n{transcript_message.jump_url}", inline=True)
405 | transcript_url = ("https://webthedev.me/ticketviewer/?url="+ transcript_message.attachments[0].url)
406 | embed2.add_field(name="**__View Link:__**", value=f"\n[Click here!]({transcript_url})", inline=True)
407 | try:
408 | message3 = await syslogc.send(embed=embed2)
409 | except discord.HTTPException:
410 | message3 = await syslogc.send(f"Ticket Channel **{tchannel.mention}** was closed by {author.mention}, it has been logged and deleted.")
411 | await tchannel.delete()
412 | TicketData.delete(connection, cursor, tchannel.id)
413 | TicketData.close(connection)
414 | @discord.ui.button(label="No", style=discord.ButtonStyle.red)
415 | async def no(self, interaction:discord.Interaction, button: discord.ui.button):
416 | author = interaction.user
417 | embed4 = discord.Embed(description="Aborting...", color=embedColor)
418 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
419 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
420 | try:
421 | await interaction.response.edit_message(embed=embed4, view=None)
422 | except discord.HTTPException:
423 | await interaction.response.edit_message("Aborting...", view=None)
424 |
425 | class ticketArchiveyesOrNoOption(discord.ui.View):
426 | @discord.ui.button(label="Yes", style=discord.ButtonStyle.green)
427 | async def yes(self, interaction:discord.Interaction, button: discord.ui.button):
428 | tchannel = interaction.channel
429 | author = interaction.user
430 | guild = interaction.guild
431 | syslogc = get(guild.channels, id=ticketLogsChannelID)
432 | connection = TicketData.connect()
433 | cursor = TicketData.cursor(connection)
434 | ticketInfo = TicketData.find(cursor, tchannel.id)
435 | categoryn = archivedTicketsCategoryID
436 | embed4 = discord.Embed(description=f'Setting Ticket to `Archived` status...', color=embedColor)
437 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
438 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
439 | try:
440 | message3 = await interaction.response.edit_message(embed=embed4, view=None)
441 | except discord.HTTPException:
442 | message3 = await interaction.response.edit_message(f"Setting Ticket to `Archived` status...", view=None)
443 | category = discord.utils.get(guild.categories, id=categoryn)
444 | await tchannel.edit(category=category)
445 | TicketData.edit(connection, cursor, ticketInfo, ticketInfo[2], "Archived")
446 | embed1 = discord.Embed(title='__**Ticket Status Changed**__', description=f'This ticket has been set to `Archived` ✅', color=embedColor)
447 | embed1.set_author(name=f'{author}', icon_url=author.display_avatar)
448 | embed1.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
449 | try:
450 | message3 = await tchannel.send(embed=embed1)
451 | except discord.HTTPException:
452 | message3 = await tchannel.send(f"**This ticket has been set to `Archived` ✅**")
453 | embed2 = discord.Embed(title='Ticket set to Archived', description=f'Ticket {tchannel.mention} has been set to `Archived` by {author.mention}', color=embedColor)
454 | embed2.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
455 | try:
456 | await syslogc.send(embed=embed2)
457 | except discord.HTTPException:
458 | await syslogc.send(f"Ticket {tchannel.mention} has been set to `Archived` by {author.mention}")
459 | TicketData.delete(connection, cursor, tchannel.id)
460 | TicketData.close(connection)
461 | @discord.ui.button(label="No", style=discord.ButtonStyle.red)
462 | async def no(self, interaction:discord.Interaction, button: discord.ui.button):
463 | author = interaction.user
464 | embed4 = discord.Embed(description="Aborting...", color=embedColor)
465 | embed4.set_author(name=f'{author}', icon_url=author.display_avatar)
466 | embed4.set_footer(text=f"{footerOfEmbeds} | {bot.user.id}", icon_url=f'{bot.user.display_avatar}')
467 | try:
468 | await interaction.response.edit_message(embed=embed4, view=None)
469 | except discord.HTTPException:
470 | await interaction.response.edit_message("Aborting...", view=None)
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------