mirror of
https://github.com/jiriks74/presence.nvim
synced 2025-06-21 20:18:57 +02:00
Skip Discord events if IPC socket is nil
- Update README - Improve logs when canceling activity
This commit is contained in:
parent
704ea67102
commit
154b8fc5a4
2 changed files with 25 additions and 20 deletions
lua/presence
|
@ -171,11 +171,11 @@ function Presence:cancel()
|
|||
|
||||
self.discord:set_activity(nil, function(err)
|
||||
if err then
|
||||
self.log:error("Failed to set nil activity in Discord: "..err)
|
||||
self.log:error(string.format("Failed to cancel activity in Discord: %s", err))
|
||||
return
|
||||
end
|
||||
|
||||
self.log:info("Sent nil activity to Discord")
|
||||
self.log:info("Canceled Discord presence")
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -391,6 +391,11 @@ end
|
|||
-- Wrap calls to Discord that require prior connection and authorization
|
||||
function Presence.discord_event(on_ready)
|
||||
return function(self, ...)
|
||||
if not self.discord.ipc_socket then
|
||||
self.log:debug("Discord IPC socket not found, skipping...")
|
||||
return
|
||||
end
|
||||
|
||||
local args = {...}
|
||||
local callback = function() on_ready(self, unpack(args)) end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue