1010import itertools
1111import aiosqlite
1212
13+ # Version number
14+ VERSION = "1.0.8"
15+
1316# Initialize logging
1417logging .basicConfig (level = logging .INFO )
1518
2528}
2629
2730def create_footer (embed , client ):
28- embed .set_footer (text = f"{ client .user .name } | ver. 1.0.7 " , icon_url = client .user .avatar .url )
31+ embed .set_footer (text = f"{ client .user .name } | v { VERSION } " , icon_url = client .user .avatar .url )
2932
3033async def init_db ():
3134 db = await aiosqlite .connect ('fixembed_data.db' )
@@ -40,7 +43,7 @@ async def load_channel_states(db):
4043 async for row in cursor :
4144 channel_states [row [0 ]] = row [1 ]
4245
43- # Enable all channels by default if not specified
46+ # Activate all channels by default if not specified
4447 for guild in client .guilds :
4548 for channel in guild .text_channels :
4649 if channel .id not in channel_states :
@@ -111,43 +114,43 @@ async def change_status():
111114 await client .change_presence (activity = discord .Activity (
112115 type = discord .ActivityType .watching , name = current_status ))
113116
114- # Enable command
117+ # Activate command
115118@client .tree .command (
116- name = 'enable ' ,
117- description = "Enable link processing in this channel or another channel" )
119+ name = 'activate ' ,
120+ description = "Activate link processing in this channel or another channel" )
118121@app_commands .describe (
119122 channel =
120- "The channel to enable link processing in (leave blank for current channel)"
123+ "The channel to activate link processing in (leave blank for current channel)"
121124)
122- async def enable (interaction : discord .Interaction ,
125+ async def activate (interaction : discord .Interaction ,
123126 channel : Optional [discord .TextChannel ] = None ):
124127 if not channel :
125128 channel = interaction .channel
126129 channel_states [channel .id ] = True
127130 await update_channel_state (client .db , channel .id , True )
128131 embed = discord .Embed (title = f"{ client .user .name } " ,
129- description = f'✅ Enabled for { channel .mention } !' ,
132+ description = f'✅ Activated for { channel .mention } !' ,
130133 color = discord .Color (0x78b159 ))
131134 create_footer (embed , client )
132135 await interaction .response .send_message (embed = embed )
133136
134- # Disable command
137+ # Deactivate command
135138@client .tree .command (
136- name = 'disable ' ,
137- description = "Disable link processing in this channel or another channel" )
139+ name = 'deactivate ' ,
140+ description = "Deactivate link processing in this channel or another channel" )
138141@app_commands .describe (
139142 channel =
140- "The channel to disable link processing in (leave blank for current channel)"
143+ "The channel to deactivate link processing in (leave blank for current channel)"
141144)
142- async def disable (interaction : discord .Interaction ,
145+ async def deactivate (interaction : discord .Interaction ,
143146 channel : Optional [discord .TextChannel ] = None ):
144147 if not channel :
145148 channel = interaction .channel
146149 channel_states [channel .id ] = False
147150 await update_channel_state (client .db , channel .id , False )
148151 embed = discord .Embed (title = f"{ client .user .name } " ,
149- description = f'❎ Disabled for { channel .mention } !' ,
150- color = discord .Color ( 0x78b159 ))
152+ description = f'❌ Deactivated for { channel .mention } !' ,
153+ color = discord .Color . red ( ))
151154 create_footer (embed , client )
152155 await interaction .response .send_message (embed = embed )
153156
@@ -191,8 +194,8 @@ async def debug_info(interaction: discord.Interaction, channel: Optional[discord
191194 # Check if FixEmbed is working in the specified channel
192195 fix_embed_status = channel_states .get (channel .id , True )
193196
194- # Check if FixEmbed is enabled or disabled in all channels
195- fix_embed_enabled = all (channel_states .get (ch .id , True ) for ch in guild .text_channels )
197+ # Check if FixEmbed is activated or deactivated in all channels
198+ fix_embed_activated = all (channel_states .get (ch .id , True ) for ch in guild .text_channels )
196199
197200 # Set embed color to Discord purple
198201 embed = discord .Embed (
@@ -204,7 +207,7 @@ async def debug_info(interaction: discord.Interaction, channel: Optional[discord
204207 name = "Status and Permissions" ,
205208 value = (
206209 f'{ f"🟢 **FixEmbed working in** { channel .mention } " if fix_embed_status else f"🔴 **FixEmbed not working in** { channel .mention } " } \n '
207- f"- { '🟢 FixEmbed enabled ' if fix_embed_status else '🔴 FixEmbed disabled ' } \n "
210+ f"- { '🟢 FixEmbed activated ' if fix_embed_status else '🔴 FixEmbed deactivated ' } \n "
208211 f"- { '🟢' if permissions .read_messages else '🔴' } Read message permission\n "
209212 f"- { '🟢' if permissions .send_messages else '🔴' } Send message permission\n "
210213 f"- { '🟢' if permissions .embed_links else '🔴' } Embed links permission\n "
@@ -219,10 +222,10 @@ async def debug_info(interaction: discord.Interaction, channel: Optional[discord
219222 name = "FixEmbed Stats" ,
220223 value = (
221224 f"```\n "
222- f"Status: { 'Enabled ' if fix_embed_enabled else 'Disabled ' } \n "
225+ f"Status: { 'Activated ' if fix_embed_activated else 'Deactivated ' } \n "
223226 f"Shard: { shard_id + 1 } \n "
224227 f"Uptime: { str (discord .utils .utcnow () - client .launch_time ).split ('.' )[0 ]} \n "
225- f"Version: 1.0.7 \n "
228+ f"Version: { VERSION } \n "
226229 f"```"
227230 ),
228231 inline = False
@@ -231,24 +234,23 @@ async def debug_info(interaction: discord.Interaction, channel: Optional[discord
231234 create_footer (embed , client )
232235 await interaction .response .send_message (embed = embed , view = SettingsView (interaction ))
233236
234-
235237# Dropdown menu for settings
236238class SettingsDropdown (ui .Select ):
237239
238240 def __init__ (self , interaction ):
239241 self .interaction = interaction
240- enabled = all (
242+ activated = all (
241243 channel_states .get (ch .id , True )
242244 for ch in interaction .guild .text_channels )
243245 options = [
244246 discord .SelectOption (
245247 label = "FixEmbed" ,
246- description = "Enable or disable the bot in all channels" ,
247- emoji = "🟢" if enabled else "🔴" # Emoji based on status
248+ description = "Activate or deactivate the bot in all channels" ,
249+ emoji = "🟢" if activated else "🔴" # Emoji based on status
248250 ),
249251 discord .SelectOption (
250252 label = "Service Settings" ,
251- description = "Configure which services are enabled " ,
253+ description = "Configure which services are activated " ,
252254 emoji = "⚙️" ),
253255 discord .SelectOption (
254256 label = "Debug" ,
@@ -263,17 +265,17 @@ def __init__(self, interaction):
263265
264266 async def callback (self , interaction : discord .Interaction ):
265267 if self .values [0 ] == "FixEmbed" :
266- enabled = all (
268+ activated = all (
267269 channel_states .get (ch .id , True )
268270 for ch in interaction .guild .text_channels )
269271 embed = discord .Embed (
270272 title = "FixEmbed Settings" ,
271- description = "**Enable/Disable FixEmbed:**\n "
272- f"{ '🟢 FixEmbed enabled ' if enabled else '🔴 FixEmbed disabled ' } \n \n "
273+ description = "**Activate/Deactivate FixEmbed:**\n "
274+ f"{ '🟢 FixEmbed activated ' if activated else '🔴 FixEmbed deactivated ' } \n \n "
273275 "**NOTE:** May take a few seconds to apply changes to all channels." ,
274276 color = discord .Color .green ()
275- if enabled else discord .Color .red ())
276- view = FixEmbedSettingsView (enabled , self .interaction )
277+ if activated else discord .Color .red ())
278+ view = FixEmbedSettingsView (activated , self .interaction )
277279 await interaction .response .send_message (embed = embed , view = view )
278280 elif self .values [0 ] == "Service Settings" :
279281 enabled_services = bot_settings .get ("enabled_services" , [])
@@ -283,8 +285,7 @@ async def callback(self, interaction: discord.Interaction):
283285 ])
284286 embed = discord .Embed (
285287 title = "Service Settings" ,
286- description =
287- f"Configure which services are enabled.\n \n **Enabled services:**\n { service_status_list } " ,
288+ description = f"Configure which services are activated.\n \n **Activated services:**\n { service_status_list } " ,
288289 color = discord .Color .blurple ())
289290 view = ServiceSettingsView (self .interaction )
290291 await interaction .response .send_message (embed = embed , view = view )
@@ -296,22 +297,20 @@ class ServicesDropdown(ui.Select):
296297 def __init__ (self , interaction , parent_view ):
297298 self .interaction = interaction
298299 self .parent_view = parent_view
299- global bot_settings # Ensure we use the global settings dictionary
300300 enabled_services = bot_settings .get ("enabled_services" , [])
301301 options = [
302302 discord .SelectOption (
303303 label = service ,
304- description = f"Enable or disable { service } links" ,
304+ description = f"Activate or deactivate { service } links" ,
305305 emoji = "✅" if service in enabled_services else "❌" )
306306 for service in ["Twitter" , "TikTok" , "Instagram" , "Reddit" ]
307307 ]
308- super ().__init__ (placeholder = "Select services to enable ..." ,
308+ super ().__init__ (placeholder = "Select services to activate ..." ,
309309 min_values = 1 ,
310310 max_values = len (options ),
311311 options = options )
312312
313313 async def callback (self , interaction : discord .Interaction ):
314- global bot_settings # Ensure we use the global settings dictionary
315314 selected_services = self .values
316315 bot_settings ["enabled_services" ] = selected_services
317316 await update_setting (client .db , "enabled_services" , selected_services )
@@ -329,7 +328,7 @@ async def callback(self, interaction: discord.Interaction):
329328 ])
330329 embed = discord .Embed (
331330 title = "Service Settings" ,
332- description = f"Configure which services are enabled .\n \n **Enabled services:**\n { service_status_list } " ,
331+ description = f"Configure which services are activated .\n \n **Activated services:**\n { service_status_list } " ,
333332 color = discord .Color .blurple ())
334333
335334 try :
@@ -363,13 +362,13 @@ def __init__(self, interaction):
363362# Toggle button for FixEmbed
364363class FixEmbedSettingsView (ui .View ):
365364
366- def __init__ (self , enabled , interaction , timeout = 180 ):
365+ def __init__ (self , activated , interaction , timeout = 180 ):
367366 super ().__init__ (timeout = timeout )
368- self .enabled = enabled
367+ self .activated = activated
369368 self .interaction = interaction
370369 self .toggle_button = discord .ui .Button (
371- label = "Enabled " if enabled else "Disabled " ,
372- style = discord .ButtonStyle .green if enabled else discord .ButtonStyle .red )
370+ label = "Activated " if activated else "Deactivated " ,
371+ style = discord .ButtonStyle .green if activated else discord .ButtonStyle .red )
373372 self .toggle_button .callback = self .toggle
374373 self .add_item (self .toggle_button )
375374 self .add_item (SettingsDropdown (interaction ))
@@ -378,39 +377,29 @@ async def toggle(self, interaction: discord.Interaction):
378377 # Acknowledge the interaction
379378 await interaction .response .defer ()
380379
381- self .enabled = not self .enabled
380+ self .activated = not self .activated
382381 for ch in self .interaction .guild .text_channels :
383- channel_states [ch .id ] = self .enabled
384- await update_channel_state (client .db , ch .id , self .enabled )
385- await update_setting (client .db , str (ch .id ), self .enabled )
386- self .toggle_button .label = "Enabled " if self .enabled else "Disabled "
387- self .toggle_button .style = discord .ButtonStyle .green if self .enabled else discord .ButtonStyle .red
382+ channel_states [ch .id ] = self .activated
383+ await update_channel_state (client .db , ch .id , self .activated )
384+ await update_setting (client .db , str (ch .id ), self .activated )
385+ self .toggle_button .label = "Activated " if self .activated else "Deactivated "
386+ self .toggle_button .style = discord .ButtonStyle .green if self .activated else discord .ButtonStyle .red
388387
389388 # Update the embed message
390389 embed = discord .Embed (
391390 title = "FixEmbed Settings" ,
392- description = "**Enable/Disable FixEmbed:**\n "
393- f"{ '🟢 FixEmbed enabled ' if self .enabled else '🔴 FixEmbed disabled ' } \n \n "
391+ description = "**Activate/Deactivate FixEmbed:**\n "
392+ f"{ '🟢 FixEmbed activated ' if self .activated else '🔴 FixEmbed deactivated ' } \n \n "
394393 "**NOTE:** May take a few seconds to apply changes to all channels." ,
395- color = discord .Color .green () if self .enabled else discord .Color .red ())
394+ color = discord .Color .green () if self .activated else discord .Color .red ())
396395
397396 try :
398- await interaction .response . edit_message (embed = embed , view = self )
397+ await interaction .edit_original_response (embed = embed , view = self )
399398 except discord .errors .NotFound :
400- # Interaction has expired, use edit_original_response instead
401- try :
402- await interaction .edit_original_response (embed = embed , view = self )
403- except discord .errors .NotFound :
404- logging .error ("Failed to edit original response: Unknown Webhook" )
405- except discord .errors .InteractionResponded :
406- # Interaction already responded, use edit_original_response
407- try :
408- await interaction .edit_original_response (embed = embed , view = self )
409- except discord .errors .NotFound :
410- logging .error ("Failed to edit original response: Unknown Webhook" )
399+ logging .error ("Failed to edit original response: Unknown Webhook" )
411400
412401 async def on_timeout (self ):
413- # Disable all components when the view times out
402+ # Deactivate all components when the view times out
414403 for item in self .children :
415404 item .disabled = True
416405
@@ -428,8 +417,8 @@ async def on_timeout(self):
428417# Settings command
429418@client .tree .command (name = 'settings' , description = "Configure FixEmbed's settings" )
430419async def settings (interaction : discord .Interaction ):
431- # Determine if FixEmbed is enabled or disabled in the interaction's guild
432- enabled = all (channel_states .get (ch .id , True ) for ch in interaction .guild .text_channels )
420+ # Determine if FixEmbed is activated or deactivated in the interaction's guild
421+ activated = all (channel_states .get (ch .id , True ) for ch in interaction .guild .text_channels )
433422
434423 embed = discord .Embed (title = "Settings" ,
435424 description = "Configure FixEmbed's settings" ,
@@ -443,7 +432,7 @@ async def on_message(message):
443432 if message .author == client .user :
444433 return
445434
446- # Check if the feature is enabled for the channel
435+ # Check if the feature is activated for the channel
447436 if channel_states .get (message .channel .id , True ):
448437 try :
449438 link_pattern = r"https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|tiktok\.com/@[^/]+/video/\d+|tiktok\.com/t/\w+|instagram\.com/(?:p|reel)/\w+|reddit\.com/r/\w+/comments/\w+/\w+)"
0 commit comments