-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
755 lines (648 loc) · 30.2 KB
/
Copy pathmain.py
File metadata and controls
755 lines (648 loc) · 30.2 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
# 1. Import necessary modules
import json
import os
import re
from typing import List
import aiohttp
import discord
from discord import app_commands
# from discord.ui import Select, View, Button
from dotenv import load_dotenv
# 2. Define constants
load_dotenv()
MY_GUILD = discord.Object(id=os.environ["guild_id"])
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
report_channels = {}
# Create a PartialEmoji object for the custom emoji
custom_tank = discord.PartialEmoji(name="tank", id=637799796891058218)
custom_healer = discord.PartialEmoji(name="healer", id=637799810287534111)
custom_dps = discord.PartialEmoji(name="dps", id=671563456742162462)
custom_craft = discord.PartialEmoji(name="crafter", id=637799971441344534)
custom_gatherer = discord.PartialEmoji(name="gatherer", id=637799947286216714)
custom_ocean_fishing = discord.PartialEmoji(name="Fisher",
id=554478937028427796)
custom_treasuremap = discord.PartialEmoji(name="treasuremap",
id=679192676486086658)
custom_blue_mage = discord.PartialEmoji(name="BlueMage", id=554479007287214090)
custom_savage_raiding = discord.PartialEmoji(name="savage",
id=638832705106346036)
custom_extreme_trials_raiding = discord.PartialEmoji(name="extreme",
id=638832720201515049)
custom_ultimate_raiding = discord.PartialEmoji(name="ultimate",
id=638832734231592965)
custom_unreal_raiding = discord.PartialEmoji(name="unreal",
id=638832750559756329)
custom_pvp = discord.PartialEmoji(name="pvp", id=638832685346979871)
custom_unsynced_content = discord.PartialEmoji(name="unsync",
id=979082924022431784)
custom_he = discord.PartialEmoji(name="he", id=637813481826942987)
custom_she = discord.PartialEmoji(name="she", id=637813570779873291)
custom_they = discord.PartialEmoji(name="they", id=637813586550456320)
custom_tools = discord.PartialEmoji(name="toolsdiscussion",
id=1013634974404051044)
custom_currentevents = discord.PartialEmoji(name="currentevents",
id=719347909048402010)
custom_orange_star = discord.PartialEmoji(name="orange_star",
id=874102281002430545)
custom_pink_star = discord.PartialEmoji(name="pink_star",
id=874102281069555752)
custom_purple_star = discord.PartialEmoji(name="purple_star",
id=874102281094717460)
custom_teal_star = discord.PartialEmoji(name="teal_star",
id=874102281002426428)
custom_green_star = discord.PartialEmoji(name="green_star",
id=983910897712001094)
custom_yellow_star = discord.PartialEmoji(name="yellow_star",
id=983911288151347202)
custom_black_star = discord.PartialEmoji(name="black_star",
id=983911288310730762)
custom_white_star = discord.PartialEmoji(name="white_star",
id=983911288176517141)
# 3. Create classes
class MyClient(discord.Client):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
self.message_id_store = self.load_message_ids()
def load_message_ids(self):
data_file = os.path.expanduser("./data.json")
if os.path.exists(data_file):
with open(data_file, "r") as f:
message_id_store = json.load(f)
print(
f"Loaded message_id_store: {message_id_store}")
return message_id_store
return {}
async def setup_hook(self):
self.tree.copy_global_to(guild=MY_GUILD)
await self.tree.sync(guild=MY_GUILD)
async def on_message_edit(self, before: discord.Message,
after: discord.Message):
if after.interaction and after.interaction.user != self.user:
await self._run_event("on_interaction", after.interaction)
def save_message_ids(client):
data_file = os.path.expanduser("./data.json")
with open(data_file, "w") as f:
json.dump(client.message_id_store, f)
print(
f"Saved message_id_store: {client.message_id_store}")
# Add this line
role_categories = {
"XIV Roles": ["Tank", "Healer", "DPS", "Crafter", "Gatherer",
"Ocean Fishing", "Maps", "Blue Mage",
"Savage Raiding", "Extreme Trials Raiding",
"Ultimate Raiding", "Unreal Raiding"],
"Pronouns": ["He/him", "She/her", "They/them"],
"Channel Access Roles": ["Tools Discussion", "Current Events"],
# "Custom Color": ["Orange Star", "Pink Star", "Purple Star", "Teal Star",
# "Green Star", "Yellow Star",
# "Black Star",
# "White Star"]
}
# Replace the RoleAdditionSelect and RoleRemovalSelect classes with RoleButton
class RoleButton(discord.ui.Button):
def __init__(self, *, role, label=None, style=None, emoji=None,
custom_id=None):
self.role = role
role_labels = {
"Tank": custom_tank,
"Healer": custom_healer,
"DPS": custom_dps,
"Crafter": custom_craft,
"Gatherer": custom_gatherer,
"Ocean Fishing": custom_ocean_fishing,
"Maps": custom_treasuremap,
"Blue Mage": custom_blue_mage,
"Savage Raiding": custom_savage_raiding,
"Extreme Trials Raiding": custom_extreme_trials_raiding,
"Ultimate Raiding": custom_ultimate_raiding,
"Unreal Raiding": custom_unreal_raiding,
"PVP": custom_pvp,
"He/him": custom_he,
"She/her": custom_she,
"They/them": custom_they,
"Tools Discussion": custom_tools,
"Current Events": custom_currentevents,
# "Orange Star": custom_orange_star,
# "Pink Star": custom_pink_star,
# "Purple Star": custom_purple_star,
# "Teal Star": custom_teal_star,
# "Green Star": custom_green_star,
# "Yellow Star": custom_yellow_star,
# "Black Star": custom_black_star,
# "White Star": custom_white_star
# Add more roles and labels if needed
}
if role.name in role_labels:
label = role.name
emoji = role_labels[role.name]
custom_id = role.name.lower().replace(" ", "_")
else:
label = role.name
super().__init__(label=label, style=discord.ButtonStyle.secondary,
emoji=emoji, custom_id=custom_id)
async def callback(self, interaction: discord.Interaction):
try:
if interaction.response.is_done():
return
# Fetch the updated member object for
# the user who clicked the button
updated_member = await interaction.guild.fetch_member(
interaction.user.id)
if self.role in updated_member.roles:
try:
await updated_member.remove_roles(self.role)
await interaction.response.send_message(
f"Successfully removed the {self.role.name} role from "
f"{updated_member.mention}.",
ephemeral=True, delete_after=30)
except Exception as e:
await send_error_message(interaction, e)
else:
try:
await updated_member.add_roles(self.role)
await interaction.response.send_message(
f"Successfully added the {self.role.name} role to "
f"{updated_member.mention}.",
ephemeral=True,
delete_after=30)
except Exception as e:
await send_error_message(interaction, e)
except Exception as e:
await send_error_message(interaction, e)
class ChannelSelectionView(discord.ui.View):
def __init__(self, interaction: discord.Interaction):
super().__init__(timeout=300)
self.interaction = interaction
self.selected_channel = None
async def interaction_check(self,
interaction: discord.Interaction) -> bool:
return self.interaction.user.id == interaction.user.id
@discord.ui.select(
placeholder="Choose a channel",
min_values=1,
max_values=1,
options=[]
)
async def channel_select(self, select: discord.ui.Select,
interaction: discord.Interaction):
self.selected_channel = int(select.values[0])
await interaction.response.send_message(
"Channel selected successfully!", ephemeral=True, delete_after=30)
self.stop()
# Create views for each group
class XIVRolesView(discord.ui.View):
def __init__(self, roles):
super().__init__(timeout=100) # Add timeout=300
# self.timeout = None # Remove this line
for role in roles:
self.add_item(RoleButton(role=role))
class PronounsView(discord.ui.View):
def __init__(self, roles):
super().__init__(timeout=100) # Add timeout=300
# self.timeout = None # Remove this line
for role in roles:
self.add_item(RoleButton(role=role))
class ChannelsView(discord.ui.View):
def __init__(self, roles):
super().__init__(timeout=100) # Add timeout=300
# self.timeout = None # Remove this line
for role in roles:
self.add_item(RoleButton(role=role))
# class ColorView(discord.ui.View):
# def __init__(self, roles):
# super().__init__(timeout=100)
# self.previous_role = None
# for role in roles:
# self.add_item(RoleButton(role=role))
#
# async def interaction_check(self, interaction: discord.Interaction) ->
# bool:
# booster_role = discord.utils.get(interaction.guild.roles,
# name="Nitro Booster")
# if booster_role is None:
# return False # Don't show the view if the Nitro Booster role
# doesn't exist
# else:
# if booster_role in interaction.user.roles:
# return True
# else:
# await interaction.response.send_message(content="You must be
# a Nitro Booster to get one of these
# roles",
# ephemeral=True,
# delete_after=30)
#
# return False
#
# async def callback(self, interaction: discord.Interaction):
# if interaction.response.is_done():
# return
# # Fetch the updated member object for the user who clicked the button
# updated_member = await
# interaction.guild.fetch_member(interaction.user.id)
#
# # Check if the user has the Nitro Booster role
# nitro_booster_role = discord.utils.get(interaction.guild.roles,
# name="Nitro Booster")
# if nitro_booster_role not in updated_member.roles:
# # Send an ephemeral message informing the user that they need
# to have the Nitro Booster role to get a
# custom color role
#
# await interaction.response.send_message("You must be a Nitro
# Booster to get one of these roles.",
# ephemeral=True,
# delete_after=30)
# return
#
# # Find the role associated with the button
# role_name = interaction.data["custom_id"].replace("_", " ")
# role = find_role(interaction.guild, role_name)
#
# if role is not None:
# if role in updated_member.roles:
# try:
# await updated_member.remove_roles(role)
# await interaction.response.send_message(
# f"Successfully removed the {role.name} role from
# {updated_member.mention}.", ephemeral=True,
# delete_after=30)
# except Exception as e:
# await send_error_message(interaction, e)
# else:
# try:
# await updated_member.add_roles(role)
# await interaction.response.send_message(
# f"Successfully added the {role.name} role to
# {updated_member.mention}.", ephemeral=True,
# delete_after=30)
# except Exception as e:
# await send_error_message(interaction, e)
# else:
# await interaction.response.send_message(f"Role '{role_name}'
# not found on the server.", ephemeral=True,
# delete_after=30)
# 4. Define functions
def is_hex(value: str) -> bool:
try:
int(value, 16)
return True
except ValueError:
return False
def is_valid_image_url(url: str) -> bool:
allowed_extensions = ('.jpg', '.jpeg', '.png', '.gif')
return url.lower().endswith(allowed_extensions)
async def get_text_channels(guild: discord.Guild) -> List[discord.TextChannel]:
return [channel for channel in guild.channels if
isinstance(channel, discord.TextChannel)]
async def send_error_message(interaction: discord.Interaction, error):
# error_channel_id = os.environ["error_channel_id"]
# error_channel = client.get_channel(error_channel_id)
print(error)
if interaction.command is not None:
command_name = interaction.command.name
print(command_name)
else:
print(
f"An error occurred in command execution by"
f" {interaction.user.mention} in {interaction.command}.")
async def search_character(first_name: str, last_name: str, server: str):
async with aiohttp.ClientSession() as session:
base_url = "https://xivapi.com/character"
search_url = f"{base_url}/search"
completed_url = f"{search_url}?name={first_name} {last_name}&" \
f"server={server}"
async with session.get(completed_url) as response:
if response.status == 200:
return await response.json()
else:
return None
async def get_character_details(character_id: int):
async with aiohttp.ClientSession() as session:
character_url = f"https://xivapi.com/character/{character_id}"
async with session.get(character_url) as response:
if response.status == 200:
return await response.json()
else:
return None
def find_role(guild: discord.Guild, role_name: str):
for role in guild.roles:
if role.name.lower() == role_name.lower():
return role
return None
# 5. Event handlers and command functions
client = MyClient(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
@client.event
async def on_interaction(interaction: discord.Interaction):
if interaction.response.is_done():
return
if interaction.type == discord.InteractionType.component:
# Fetch the updated member object for the user who clicked the button
updated_member = await interaction.guild.fetch_member(
interaction.user.id)
# Find the role associated with the button
role_name = interaction.data["custom_id"].replace("_", " ")
role = find_role(interaction.guild, role_name)
if role is not None:
if role in updated_member.roles:
try:
await updated_member.remove_roles(role)
await interaction.response.send_message(
f"Successfully removed the {role.name} role from "
f"{updated_member.mention}.",
ephemeral=True,
delete_after=30)
except Exception as e:
await send_error_message(interaction, e)
else:
try:
await updated_member.add_roles(role)
await interaction.response.send_message(
f"Successfully added the {role.name} role to "
f"{updated_member.mention}.",
ephemeral=True,
delete_after=30)
except Exception as e:
await send_error_message(interaction, e)
else:
await interaction.response.send_message(
f"Role '{role_name}' not found on the server.", ephemeral=True,
delete_after=30)
elif interaction.type == discord.InteractionType.application_command:
# If you have other types of interactions (e.g. slash commands),
# handle them here
pass
@client.tree.command()
@app_commands.describe(
first_name="The first name of the character",
last_name="The last name of the character",
server="The server of the character"
)
async def lookup_character(interaction: discord.Interaction, first_name: str,
last_name: str, server: str):
try:
await interaction.response.defer()
character_data = await search_character(first_name, last_name, server)
if character_data:
results = character_data["Results"]
if results:
character = results[0]
character_id = character["ID"]
character_details = await get_character_details(character_id)
main_class = character_details["Character"]["ActiveClassJob"][
"Name"]
main_class_level = \
character_details["Character"]["ActiveClassJob"]["Level"]
embed = discord.Embed(title=character["Name"],
description=f"Server:"
f" {character['Server']}\n"
f"Main Class: "
f"{main_class} "
f"(Level "
f"{main_class_level})")
embed.set_thumbnail(url=character["Avatar"])
await interaction.edit_original_response(embed=embed)
else:
await interaction.edit_original_response(
content="No character found.")
else:
await interaction.edit_original_response(
content="An error occurred while looking up the character.")
except Exception as e:
await interaction.edit_original_response(
content="An error occurred while looking up the character.")
await send_error_message(interaction, e)
@client.tree.command(description="Post role buttons in the specified channel")
@app_commands.describe(
channel="The target channel for posting role buttons"
)
async def post_role_buttons(interaction: discord.Interaction,
channel: discord.TextChannel):
if not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(
"You do not have the required permissions to use this command.",
ephemeral=True, delete_after=30)
return
try:
guild = interaction.guild
target_channel = channel
for category, role_names in role_categories.items():
category_roles = [role for role in guild.roles if
role.name in role_names]
if category == "XIV Roles":
message = "Please react to this message according to any " \
"roles that you would identify as. Keep in " \
"mind we may ping these roles to fill in groups " \
"and organize running content together. If " \
"you do not want to be pinged, you can mute that " \
"in the server settings. "
view = XIVRolesView(category_roles)
elif category == "Pronouns":
message = "Please react to this message according to the " \
"pronoun that you wish to be called by. You " \
"can repeat this process to remove the role again. "
view = PronounsView(category_roles)
elif category == "Channel Access Roles":
message = "XIV Tools Discussion: React to this role to gain " \
"access to a text channel for discussion of XIV " \
"tools (mods, plugins, ACT).\n Current Events: " \
"Provides access to discuss folks' feelings and " \
"thoughts about what’s going on outside Eorzea. " \
"There will be a zero tolerance policy for " \
"breaking any of the server's rules, and if you " \
"are seen glorifying or joking about violence or " \
"racism in any way, you may be immediately " \
"removed " \
"from the FC/Discord."
view = ChannelsView(category_roles)
# elif category == "Custom Color":
# message = "NITRO BOOSTER PERK! If you boost our server,
# you can select a custom color for your name!"
# view = ColorView(category_roles)
message_text = f"**{category}** \n\n {message}"
sent_message = await target_channel.send(message_text, view=view)
client.message_id_store[category] = sent_message.id
# Save message IDs to data.json
await interaction.response.send_message(
"Role buttons posted in the target channel.", ephemeral=True,
delete_after=30)
save_message_ids(client) # Save message IDs to data.json
except Exception as e:
await interaction.response.send_message(
"An error occurred while looking up the character.")
await send_error_message(interaction, e)
@client.tree.command(description="Send an announcement to a channel")
async def announcement(interaction: discord.IntegrationAccount,
channel_name: str = None):
if not interaction.user.guild_permissions.administrator:
await interaction.response.send_message(
"You do not have the required permissions to use this command.",
ephemeral=True, delete_after=30)
else: # Add an 'else' block
announcement_modal = SendAnnouncementMessage(channel_name)
await interaction.response.send_modal(announcement_modal)
class SendAnnouncementMessage(discord.ui.Modal,
title="Send an announcement to a channel"):
def __init__(self, channel_name=None):
super().__init__()
self.channel_name = channel_name
self.announcement_title = discord.ui.TextInput(
style=discord.TextStyle.short,
label="Title",
required=True,
placeholder="Enter Title"
)
self.announcement_message = discord.ui.TextInput(
style=discord.TextStyle.long,
label="Message",
required=True,
max_length=1024,
placeholder="Enter your message"
)
self.announcement_url = discord.ui.TextInput(
style=discord.TextStyle.short,
label="Image",
required=False,
max_length=100,
placeholder="Insert a url with an image (should end with .jpg, "
".png, etc."
)
self.announcement_channel_name = discord.ui.TextInput(
style=discord.TextStyle.short,
label="Channel Name",
default=self.channel_name if self.channel_name else None,
required=True,
placeholder="Insert a channel name"
)
self.announcement_custom_color = discord.ui.TextInput(
style=discord.TextStyle.short,
label="Custom Color",
required=False,
placeholder="Insert a hex color code (e.g. FF0000)",
min_length=6,
max_length=6
)
self.add_item(self.announcement_title)
self.add_item(self.announcement_message)
self.add_item(self.announcement_url)
self.add_item(self.announcement_channel_name)
self.add_item(self.announcement_custom_color)
async def on_submit(self, interaction: discord.Interaction):
title = self.announcement_title.value
message = self.announcement_message.value
url = self.announcement_url.value
# Use the provided channel_name
channel_name = self.announcement_channel_name.value
mention_pattern = re.compile(r'<#(\d+)>')
if mention_pattern.match(channel_name):
channel_id = int(mention_pattern.match(channel_name).group(1))
target_channel = discord.utils.get(
interaction.guild.text_channels, id=channel_id)
channel_name = target_channel.name
else:
target_channel = discord.utils.get(
interaction.guild.text_channels, name=channel_name)
if self.announcement_custom_color.value:
if is_hex(self.announcement_custom_color.value):
color = discord.Color(
int(self.announcement_custom_color.value, 16))
else:
await interaction.response.send_message(
"Invalid hex color value provided. Please provide a valid"
" hex "
"color code (e.g. FF0000).",
ephemeral=True, delete_after=30)
return
else:
color = discord.Color.green()
try:
target_channel = discord.utils.get(
interaction.guild.text_channels, name=channel_name)
if target_channel is not None:
if target_channel.permissions_for(
interaction.guild.me).send_messages:
embed = discord.Embed(title=title, description=message,
color=color)
if url and is_valid_image_url(url):
embed.set_image(url=url)
await target_channel.send(embed=embed)
await interaction.response.send_message(
"Announcement sent successfully!", ephemeral=True,
delete_after=30)
else:
await interaction.response.send_message(
"I do not have permission to send messages in "
"the specified channel.",
ephemeral=True,
delete_after=30)
else:
await interaction.response.send_message(
"Invalid channel name provided.", ephemeral=True,
delete_after=30)
except Exception as e:
await interaction.response.send_message(
"An error occurred while sending the announcement.",
ephemeral=True,
delete_after=30)
await send_error_message(interaction, e)
async def on_error(self, interaction: discord.Interaction, error):
print(self, interaction, error)
@client.tree.command(description="Request an invitation")
async def requestinvite(interaction: discord.Interaction):
request_invitation_modal = RequestInvitationModal(client)
await interaction.response.send_modal(request_invitation_modal)
class RequestInvitationModal(discord.ui.Modal, title="Request an Invitation"):
def __init__(self, client): # Add the client parameter
super().__init__()
self.client = client # Save the client instance
self.ffxiv_username = discord.ui.TextInput(
style=discord.TextStyle.short,
label="FFXIV Username",
required=True,
placeholder="Enter your FFXIV Username"
)
self.message = discord.ui.TextInput(
style=discord.TextStyle.long,
label="Message",
required=False,
max_length=1024,
placeholder="Enter your message"
)
self.add_item(self.ffxiv_username)
self.add_item(self.message)
async def on_submit(self, interaction: discord.Interaction):
ffxiv_username = self.ffxiv_username.value
message = self.message.value
target_channel_id = int(os.environ["invitation_channel"])
print(os.environ["invitation_channel"])
target_channel = self.client.get_channel(target_channel_id)
try:
# Send the embed message
embed = discord.Embed(title="Invitation Request",
description=f'**FFXIV Username:**'
f' {ffxiv_username}\n'
f'**Message:** {message}',
color=discord.Color.green())
sent_message = await target_channel.send(content="@everyone",
embed=embed)
# Add a checkmark reaction to the sent message
await sent_message.add_reaction("✅")
await interaction.response.send_message(
"Your invitation request has been sent!", ephemeral=True,
delete_after=30)
except Exception as e:
await interaction.response.send_message(
"Failed to send your request. Please try again later.",
ephemeral=True,
delete_after=30)
await send_error_message(interaction, e)
async def on_error(self, interaction: discord.Interaction, error):
print(self, interaction, error)
client.run(os.environ["token"])