Closed MincoMK closed 3 years ago
Is this happening directly when you start the bot or when the bot is running for a while? And does the console show a reconnect?
Is this happening directly when you start the bot or when the bot is running for a while? And does the console show a reconnect?
No, It happens when I type !command
in Discord
You have to fetch the user, the reaction (for message reaction listener) and so on. I don't know why this is not done by DiscordPHP itself... @davidcole1340
But the issue in your code is that you've tried to get the Author
again from the Message
, that won't work. If you want the author in the Message
fetch the message.
$channel->messages->fetch($message->id)->done(function($message){
var_dump($message);
});
Have a look in your Discord developer settings and enable presence updates and server members:
The problem likely is that when you call $discord_full_id = "{$message->author->user}";
, $message->author
is already a User
object, therefore it doesn't have a user
parameter
Have a look in your Discord developer settings and enable presence updates and server members:
The problem likely is that when you call
$discord_full_id = "{$message->author->user}";
,$message->author
is already aUser
object, therefore it doesn't have auser
parameter
But var_dump($msg->author)
returns "NULL"
++ How to set my bot's msg like playing Minecraft without "Playing"? ++ I want to make "10 Users using my Bot" ++ How to get all servers, How to announce in all servers?
lemme redo that code you started with in the first place, you will learn a lot of things from this, as you seem to be example orientated:
$discord->on('message', function ($message, $discord) {
// $discord->id is the bots user id, the author id is contained in $message->author->id, NOT $message->author
if ($message->author->id == $discord->id) {
return;
}
// some example extracts you did in a VERY complex way whilst not needed
$guild = $message->channel->guild;
$botuser = $guild->members->offsetGet($discord->id);
$channel = $message->channel;
// var_dump doesn't require an echo, it already does that
var_dump($message->author); // [ THIS ]
if (fnmatch('!*', $message->content)) {
// way too complext thinking as well here using $message->channel->messages->delete($message);, just
$message->delete();
}
});
++ How to set my bot's msg like playing Minecraft without "Playing"? Very simple: NOT, bots are not allowed to use custom status messages.
++ I want to make "10 Users using my Bot" see #420
++ How to get all servers, How to announce in all servers? $discord->guilds contains all guilds the bot is in, however, without knowing a channel in that guild to announce to (and you surely would not want to announce in all channels), what you want to do there ain't easy without knowing more.
$message->author Is null
This is My code "[ THIS ]" Returns "NULL"
Why?
I got a null->user->... error.
BotUser code successfully blocks bot-executing commands (I got a very big bug that bot executes same cmd, loop)
I'm both NewBie of English, DiscordPHP, PHP Object. Pls execute it, and read.
++ How to get user by Mention? EX) !dmbot \@Minco#0000 How to make bot DM to \@Minco#0000 when I execute this cmd? (Do not care about \, Just for no-GitHub-mention)