11"""Full Doku on: https://github.com/NapoII/Discord_Rust_Team_bot"
22-----------------------------------------------
3- Diese COG ist für Spielerkarten, um die letzte Aktiviti zu sehen.
4- e.g. :
5- Wohnort ?
3+ This COG is for player cards to see the latest activiti.
64Team note: ?
7- aktualisiert vor 7 Minuten
5+ updated 7 minutes ago
86FRED
9- 🔴 vor einem Monat
7+ 🔴 one month ago
108ServerZeit: 223.61h
119note: Close by
1210Player ID: 244928103
1816from discord .ext import commands , tasks
1917from discord .ui import Select , View
2018from numpy import append
21- import asyncio
19+
2220
2321from util .__funktion__ import *
2422
6462player_observation_channel_id = int (read_config (
6563 config_dir , "Channel" , "player_observation_channel_id" ))
6664
67- Rust_Bot_Channel_ID = read_config (config_dir , "Channel" , "player_observation_channel_id" )
65+ Rust_Bot_Channel_ID = read_config (
66+ config_dir , "Channel" , "player_observation_channel_id" )
6867if Rust_Bot_Channel_ID == None :
6968 Rust_Bot_Channel_ID = 1
7069Rust_Bot_Channel_ID = int (Rust_Bot_Channel_ID )
7170
71+
7272class New_player (commands .Cog ):
7373 def __init__ (self , bot : commands .Bot ) -> None :
7474 self .bot = bot
@@ -82,24 +82,28 @@ async def choise_team(self, interaction: discord.Interaction, player_name: str,
8282 self .player_name = player_name
8383 self .player_note = player_note
8484
85- thinking = self . bot . get_emoji ( 123456789 ) # replace with your thinking emoji ID
86-
85+ # replace with your thinking emoji ID
86+ thinking = self . bot . get_emoji ( 123456789 )
8787
8888 # Send the embed with the thinking animation
89- embed = discord .Embed (title = "Adding player..." , description = f"{ thinking } Thinking..." , color = discord .Color .blurple ())
89+ embed = discord .Embed (
90+ title = "Adding player..." , description = f"{ thinking } Thinking..." , color = discord .Color .blurple ())
9091 msg = await interaction .response .send_message (embed = embed , ephemeral = True , )
9192
92- battlemetrics_server_id = read_config (config_dir , "Rust" , "battlemetrics_server_id" )
93+ battlemetrics_server_id = read_config (
94+ config_dir , "Rust" , "battlemetrics_server_id" )
9395
9496 if "id-" in player_name :
9597 player_id = player_name .split ("id:" )[1 ]
9698
9799 else :
98- player_id = get_player_id_from_name (player_name , battlemetrics_server_id )
100+ player_id = get_player_id_from_name (
101+ player_name , battlemetrics_server_id )
99102
100103 if player_id == None :
101104 s_url = f"https://www.battlemetrics.com/players?filter%5Bsearch%5D={ player_name } &filter%5BplayerFlags%5D=&filter%5Bservers%5D={ battlemetrics_server_id } &sort=-lastSeen"
102- embed = discord .Embed (title = f"No search results with { player_name } " , url = s_url , description = "Try to find the player by yourself and add the ID to the next request with `id:{battlemetrics_player_id}`." , color = 0xff0000 )
105+ embed = discord .Embed (title = f"No search results with { player_name } " , url = s_url ,
106+ description = "Try to find the player by yourself and add the ID to the next request with `id:{battlemetrics_player_id}`." , color = 0xff0000 )
103107 await interaction .response .send_message (embed = embed , ephemeral = True )
104108 else :
105109 player_id = int (player_id )
@@ -143,23 +147,24 @@ async def choise_team(self, interaction: discord.Interaction, player_name: str,
143147 if player_online_status == False or player_online_status == "never_played" :
144148 if player_online_status == "never_played" :
145149 embed = discord .Embed (title = f"{ Player_name } " , url = f"https://www.battlemetrics.com/players/{ player_id } " ,
146- description = ("❌ | ID: " + str (player_id )), color = 0xff0000 )
150+ description = ("❌ | ID: " + str (player_id )), color = 0xff0000 )
147151 value = f"❌ `Never played on that Server` ❌ | note: `{ player_note } `"
148152 embed .add_field (name = Player_name , value = value , inline = True )
149153 else :
150154 embed = discord .Embed (title = f"{ Player_name } " , url = f"https://www.battlemetrics.com/players/{ player_id } " ,
151- description = ("🔴 | ID: " + str (player_id )), color = 0xff0000 )
155+ description = ("🔴 | ID: " + str (player_id )), color = 0xff0000 )
152156 embed .add_field (name = "Last Seen" ,
153157 value = f"{ player_lastSeen } " , inline = True )
154158 embed .add_field (
155159 name = "Note" , value = f"{ player_note } " , inline = True )
156160 embed .set_footer (text = f"Select team:" )
157161 else :
158162 embed = discord .Embed (title = f"{ Player_name } " , url = f"https://www.battlemetrics.com/players/{ player_id } " ,
159- description = f"🟢 | ID: { player_id } " , color = 0xff8040 )
163+ description = f"🟢 | ID: { player_id } " , color = 0xff8040 )
160164 embed .add_field (name = "Online since" ,
161165 value = f"{ player_lastSeen } " , inline = True )
162- embed .add_field (name = "Note" , value = f"{ player_note } " , inline = True )
166+ embed .add_field (
167+ name = "Note" , value = f"{ player_note } " , inline = True )
163168 embed .set_footer (text = f"Select team:" )
164169
165170 Team_list = Team_choice (file_path_Team_data )
@@ -204,16 +209,11 @@ async def my_callback(interaction):
204209 select .callback = my_callback
205210 view = View ()
206211 view .add_item (select )
207-
212+
208213 if msg is not None :
209214 await msg .edit (embed = embed , view = view )
210215 else :
211- await interaction .channel .send (embed = embed , delete_after = 10 , view = view )
212-
213-
214-
215-
216-
216+ await interaction .channel .send (embed = embed , delete_after = 30 , view = view )
217217
218218
219219class Confirm_say (discord .ui .View ):
@@ -250,7 +250,7 @@ class modal_New_team(ui.Modal, title="New Team",):
250250 log ("modal_New_team: New_Team_name | New_team_note |" )
251251
252252 async def on_submit (self , interaction : discord .Interaction ):
253-
253+
254254 embed = discord .Embed (title = self .New_Team_name ,
255255 description = self .New_team_note , color = 0xc0c0c0 )
256256 view = Confirm_say ()
@@ -275,7 +275,6 @@ async def on_submit(self, interaction: discord.Interaction):
275275 Team_Card_embed_id = 0
276276 log (f'Confirmed... self.confirm_Button = { self .confirm_Button } ' )
277277
278-
279278 JSOn_data = open_JSOn_File (file_path_Team_data )
280279 JSOn_data = add_Team (JSOn_data , self .New_Team_name ,
281280 self .New_team_note , Team_Card_embed_id )
@@ -286,7 +285,8 @@ async def on_submit(self, interaction: discord.Interaction):
286285
287286 # add_player(dict, team, name, id, note):
288287
289- JSOn_data = add_player (JSOn_data , self .New_Team_name , player_name_str , player_id_int , player_note_str )
288+ JSOn_data = add_player (
289+ JSOn_data , self .New_Team_name , player_name_str , player_id_int , player_note_str )
290290
291291 Fill_JSOn_File (file_path_Team_data , JSOn_data )
292292
@@ -332,12 +332,13 @@ async def on_submit(self, interaction: discord.Interaction):
332332 break
333333 #player_observation_channel_id = int(read_config(config_dir, "Channel", "player_observation_channel_id"))
334334 try :
335- player_observation_channel = interaction .client .get_channel (player_observation_channel_id )
335+ player_observation_channel = interaction .client .get_channel (
336+ player_observation_channel_id )
336337 msg = await player_observation_channel .fetch_message (embed_ID_list [x ])
337338 await msg .delete ()
338- log (f"No msg delt" ,"blue" )
339+ log (f"No msg delt" , "blue" )
339340 except :
340- log (f"No msg to delt" ,"blue" )
341+ log (f"No msg to delt" , "blue" )
341342
342343 dictionary = {"Teams" : {}}
343344 Fill_JSOn_File (file_path_Team_data , dictionary )
@@ -485,7 +486,8 @@ async def my_callback(interaction: discord.Interaction):
485486 JSOn_data = delt_Team (JSOn_data , Team_name )
486487 Fill_JSOn_File (file_path_Team_data , JSOn_data )
487488
488- player_observation_channel = interaction .client .get_channel (player_observation_channel_id )
489+ player_observation_channel = interaction .client .get_channel (
490+ player_observation_channel_id )
489491 log (f"msg delt: { embed_id } : Team embed ({ Team_name } )" )
490492 msg = await player_observation_channel .fetch_message (embed_id )
491493 await msg .delete ()
@@ -641,19 +643,23 @@ async def myLoop(self, bot,):
641643 await User .send (embed = embed )
642644
643645 try :
644- player_observation_channel = self .bot .get_channel (player_observation_channel_id )
646+ player_observation_channel = self .bot .get_channel (
647+ player_observation_channel_id )
645648 msg = await player_observation_channel .fetch_message (Team_embed_id )
646649 await msg .edit (embed = embed )
647- log (f"Discord: Edit Embed from Team [{ Team_Name } ] msg.id: [{ msg .id } ]" )
650+ log (
651+ f"Discord: Edit Embed from Team [{ Team_Name } ] msg.id: [{ msg .id } ]" )
648652 except :
649653 try :
650654 JSOn_data = open_JSOn_File (file_path_Team_data )
651- player_observation_channel = self .bot .get_channel (player_observation_channel_id )
655+ player_observation_channel = self .bot .get_channel (
656+ player_observation_channel_id )
652657 Team_Card_embed = await player_observation_channel .send (embed = embed , view = Sub_button ())
653658 Team_Card_embed_id = (Team_Card_embed .id )
654659 JSOn_data ["Teams" ][Team_Name ]["embed_id" ] = Team_Card_embed_id
655660 Fill_JSOn_File (file_path_Team_data , JSOn_data )
656- log (f"Discord: send new Embed from Team [{ Team_Name } ] msg.id: [{ Team_Card_embed_id } ]" )
661+ log (
662+ f"Discord: send new Embed from Team [{ Team_Name } ] msg.id: [{ Team_Card_embed_id } ]" )
657663 except :
658664 pass
659665
0 commit comments