-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot-v6-transferred.py
More file actions
159 lines (135 loc) · 6.37 KB
/
bot-v6-transferred.py
File metadata and controls
159 lines (135 loc) · 6.37 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
import discord
from discord.ext import commands, tasks
from discord.ui import Button, View
import copy
import json
import base64
import requests
import io
import math
import asyncio
from collections import defaultdict
TOKEN = 'MTM1OTQ4Njc3MjM2NjY3MjAyMg.GNnFP5.MzwGW0qOss4baLDS-ePP0GFmNxk-4vgDvT8ipM'
BUG_REPORT_CHANNEL_ID = 1361692561198153971
BUG_REPORT_ADMIN_CHANNEL_ID = 1368205816573853796
BUG_REPORT_QUEUE_CHANNEL_ID = 1368206019922100257
BUG_REPORT_ARCHIVE_CHANNEL_ID = 1368207149758418994
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='-', intents=intents)
report_cooldown = {}
SPAM_LIMIT = 3
SPAM_WINDOW = 60
class BugReportReviewView(View):
def __init__(self, reporter_id, report_data):
super().__init__(timeout=None)
self.reporter_id = reporter_id
self.report_data = report_data
async def disable_all_buttons(self, interaction, status):
for item in self.children:
item.disabled = True
embed = interaction.message.embeds[0]
embed.title = f"Bug Report ({status})"
await interaction.message.edit(embed=embed, view=self)
@discord.ui.button(label="Accept", style=discord.ButtonStyle.success, custom_id="bug_report_accept")
async def accept_report(self, interaction: discord.Interaction, button: Button):
await interaction.response.defer()
await self.disable_all_buttons(interaction, "Accepted")
queue_channel = bot.get_channel(BUG_REPORT_QUEUE_CHANNEL_ID)
embed = discord.Embed(
title=f"Bug Report (Accepted)",
description=self.report_data['description'],
color=discord.Color.green()
)
embed.set_author(name=f"Reported by {self.report_data['reporter']['discord_username']} ({self.report_data['reporter']['in_game_name']})")
await queue_channel.send(embed=embed)
try:
user = await bot.fetch_user(int(self.report_data['reporter']['discord_id']))
embed = discord.Embed(
title="Bug Report Accepted",
description="Your report has been accepted and added to our queue.",
color=discord.Color.green()
)
embed.add_field(name="Details", value=self.report_data['description'])
await user.send(embed=embed)
except:
pass
archive_channel = bot.get_channel(BUG_REPORT_ARCHIVE_CHANNEL_ID)
await archive_channel.send(embed=interaction.message.embeds[0])
@discord.ui.button(label="Reject", style=discord.ButtonStyle.danger, custom_id="bug_report_reject")
async def reject_report(self, interaction: discord.Interaction, button: Button):
await interaction.response.defer()
await self.disable_all_buttons(interaction, "Rejected")
try:
user = await bot.fetch_user(int(self.report_data['reporter']['discord_id']))
embed = discord.Embed(
title="Bug Report Reviewed",
description="Your report was reviewed but not accepted.",
color=discord.Color.red()
)
embed.add_field(name="Details", value=self.report_data['description'])
await user.send(embed=embed)
except:
pass
archive_channel = bot.get_channel(BUG_REPORT_ARCHIVE_CHANNEL_ID)
await archive_channel.send(embed=interaction.message.embeds[0])
@bot.event
async def on_message(message):
await bot.process_commands(message)
if message.channel.id == BUG_REPORT_CHANNEL_ID and message.webhook_id:
try:
report_data = json.loads(message.content)
if report_data.get('type') == 'bug_report':
reporter_id = int(report_data['reporter']['discord_id'])
current_time = asyncio.get_event_loop().time()
if reporter_id not in report_cooldown:
report_cooldown[reporter_id] = []
report_cooldown[reporter_id] = [
t for t in report_cooldown[reporter_id]
if current_time - t < SPAM_WINDOW
]
if len(report_cooldown[reporter_id]) >= SPAM_LIMIT:
try:
user = await bot.fetch_user(reporter_id)
embed = discord.Embed(
title="Too Many Reports",
description="Please try again later.",
color=discord.Color.red()
)
await user.send(embed=embed)
except:
pass
return
report_cooldown[reporter_id].append(current_time)
admin_channel = bot.get_channel(BUG_REPORT_ADMIN_CHANNEL_ID)
embed = discord.Embed(
title="New Bug Report",
description=report_data['description'],
color=discord.Color.orange()
)
embed.add_field(name="Reporter", value=f"{report_data['reporter']['discord_username']} ({report_data['reporter']['in_game_name']})")
embed.add_field(name="Timestamp", value=report_data['timestamp'])
if report_data.get('attachment'):
embed.add_field(name="Attachment", value=report_data['attachment'])
view = BugReportReviewView(reporter_id, report_data)
await admin_channel.send(embed=embed, view=view)
try:
user = await bot.fetch_user(reporter_id)
embed = discord.Embed(
title="Report Received",
description="Your bug report has been submitted for review.",
color=discord.Color.blue()
)
embed.add_field(name="Details", value=report_data['description'])
await user.send(embed=embed)
except:
pass
except json.JSONDecodeError:
pass
except Exception as e:
print(f"Error processing bug report: {e}")
@bot.event
async def on_ready():
bot.add_view(BugReportReviewView(reporter_id=None, report_data=None))
print(f"Bot is ready as {bot.user}")
bot.run(TOKEN)