-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
147 lines (110 loc) · 5.79 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import time, discord, random, json, shutil, datetime, os, logging
from discord.ext import commands
from colorama import *
os.system('cls')
bot = commands.Bot(command_prefix="$", intents=discord.Intents.all())
center = shutil.get_terminal_size().columns
date = datetime.datetime.now().strftime("%Y-%m-%d %I:%M %p")
config = {
"token":"",
"prefix":"",
"name":"Ghostface Ticket Bot",
"creator":"@sacrifice.zip",
"owner_id":"",
"support_id":""
}
banner = f"""
▄████ ██░ ██ ▒█████ ██████ ▄▄▄█████▓ █████▒▄▄▄ ▄████▄ ▓█████
██▒ ▀█▒▓██░ ██▒▒██▒ ██▒▒██ ▒ ▓ ██▒ ▓▒▓██ ▒▒████▄ ▒██▀ ▀█ ▓█ ▀
▒██░▄▄▄░▒██▀▀██░▒██░ ██▒░ ▓██▄ ▒ ▓██░ ▒░▒████ ░▒██ ▀█▄ ▒▓█ ▄ ▒███
░▓█ ██▓░▓█ ░██ ▒██ ██░ ▒ ██▒░ ▓██▓ ░ ░▓█▒ ░░██▄▄▄▄██ ▒▓▓▄ ▄██▒▒▓█ ▄
░▒▓███▀▒░▓█▒░██▓░ ████▓▒░▒██████▒▒ ▒██▒ ░ ░▒█░ ▓█ ▓██▒▒ ▓███▀ ░░▒████▒
░▒ ▒ ▒ ░░▒░▒░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░ ▒ ░░ ▒ ░ ▒▒ ▓▒█░░ ░▒ ▒ ░░░ ▒░ ░
░ ░ ▒ ░▒░ ░ ░ ▒ ▒░ ░ ░▒ ░ ░ ░ ░ ▒ ▒▒ ░ ░ ▒ ░ ░ ░
░ ░ ░ ░ ░░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ░
░
Created by: @sacrifice.zip"""
logging.getLogger('discord.client').setLevel(logging.WARNING)
logging.getLogger('discord.gateway').setLevel(logging.WARNING)
@bot.event
async def on_ready():
for line in banner.splitlines():
os.system(f'title Ghostface Ticket Bot {datetime.datetime.now().strftime((f"%Y-%m-%d %I:%M %p"))}')
print(Fore.RED + line.center(center) + Fore.RESET)
print('\033[?25l', end="")
@bot.event
async def on_member_join(member):
role_name = "Members"
role = discord.utils.get(member.guild.roles, name=role_name)
await member.add_roles(role)
with open('db/database.json', 'r') as f:
data = json.load(f)
if str(member.id) not in data['open']:
data['open'][str(member.id)] = False
with open('db/database.json', 'w') as f:
json.dump(data, f, indent=4)
@bot.command()
async def create(ctx):
author_id = str(ctx.author.id)
guild = ctx.guild
with open('db/database.json', 'r') as f:
data = json.load(f)
if author_id in data['open'] and not data['open'][author_id]:
data['open'][author_id] = True
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
ctx.author: discord.PermissionOverwrite(read_messages=True)
}
channel = await guild.create_text_channel(f"ticket-{author_id}", overwrites=overwrites)
embed = discord.Embed(
title=config['name'],
description=f"<@{author_id}> ticket has successfully been created.",
color=0x000001
)
embed.set_footer(text=f"{config['name']} | Created by: {config['creator']}")
await ctx.message.reply(embed=embed)
channel_embed = discord.Embed(
title=f"{config['name']}",
description=f"<@&{config['support_id']}> Ticket has been made.",
color = 0x000001
)
channel_embed.add_field(name="", value=f"<@{author_id}> Please be patient until our support team can respond to your ticket. If you have an issue or order please give us a breif description on whats going on!")
await channel.send(embed=channel_embed)
with open('db/database.json', 'w') as f:
json.dump(data, f, indent=4)
else:
embed = discord.Embed(
title=config['name'],
description=f"<@{author_id}> you already have an ongoing ticket.",
color=0x000001
)
embed.set_footer(text=f"{config['name']} | Created by: {config['creator']}")
await ctx.message.reply(embed=embed)
@bot.command()
async def close(ctx):
author_id = str(ctx.author.id)
guild = ctx.guild
with open('db/database.json', 'r') as f:
data = json.load(f)
if author_id in data['open'] and data['open'][author_id]:
try:
channel_name = f"ticket-{author_id}"
channel = discord.utils.get(guild.channels, name=channel_name)
if channel:
await channel.delete()
data['open'][author_id] = False
with open('db/database.json', 'w') as f:
json.dump(data, f, indent=4)
else:
embed = discord.Embed(
title=config['name'],
description=f"<@{author_id}> You have no open tickets.",
color=0x000001
)
embed.set_footer(text=f"{config['name']} | Created by: {config['creator']}")
await ctx.message.reply(embed=embed)
except Exception as e:
with open('failed/error.txt', 'w') as f:
f.write(f"{date}\n{author_id}:\n{e}")
bot.run(config['token'])