This repository was archived by the owner on Feb 14, 2025. It is now read-only.
File tree 3 files changed +15
-5
lines changed
3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 27
27
*/
28
28
class Ping extends Command
29
29
{
30
+ /**
31
+ * Latest ping from Discord gateway
32
+ *
33
+ * @var integer
34
+ */
35
+ protected ?int $ lastPing = null ;
36
+
30
37
/**
31
38
* configure
32
39
*
@@ -38,6 +45,10 @@ public function configure(): void
38
45
$ this ->description = "Displays bot's latency. " ;
39
46
$ this ->aliases = ["latency " , "ms " ];
40
47
$ this ->category = "utility " ;
48
+
49
+ $ this ->discord ->on ('heartbeat-ack ' , function ($ time ) {
50
+ $ this ->lastPing = intval ($ time );
51
+ });
41
52
}
42
53
43
54
/**
@@ -50,7 +61,6 @@ public function configure(): void
50
61
public function handle ($ msg , $ args ): void
51
62
{
52
63
global $ language ;
53
- $ diff = intval ($ msg ->timestamp ->floatDiffInRealSeconds () * 1000 );
54
- $ msg ->channel ->sendMessage (sprintf ($ language ->getTranslator ()->trans ('commands.ping.reply ' ), $ diff ));
64
+ $ msg ->channel ->sendMessage (sprintf ($ language ->getTranslator ()->trans ('commands.ping.reply ' ), $ this ->lastPing ?? "... " ));
55
65
}
56
66
}
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ commands:
90
90
# 4: reciever 5: amount 6: emote
91
91
pay_msg : " Money Sent!\n\n %s - %s %s --> %s + %s %s"
92
92
ping :
93
- reply : " Your ping took %s ms to arrive ."
93
+ reply : " My ping is %s ms."
94
94
slots :
95
95
no_amount : " You have to write a pay amount."
96
96
no_numeric_arg : " Pay amount should be numeric."
Original file line number Diff line number Diff line change @@ -89,8 +89,8 @@ commands:
89
89
# 1: sender 2: amount 3: emote
90
90
# 4: reciever 5: amount 6: emote
91
91
pay_msg : " Para gönderildi!\n\n %s - %s %s --> %s + %s %s"
92
- ping :
93
- reply : " Mesajınız %s milisaniye içinde bota ulaştı ."
92
+ " ping " :
93
+ reply : " Botun pingi %s ms ."
94
94
slots :
95
95
no_amount : " Bahis miktarını girmelisin."
96
96
no_numeric_arg : " Bahis miktarı sayısal olmalıdır."
You can’t perform that action at this time.
0 commit comments