İçeriğe geç
BETA Voxnup şu an beta aşamasında. Hatalar ve eksiklikler olabilir — geri bildiriminiz bizim için çok değerli! Geri bildirim gönder
Voxnup

Bot commands, events and methods (Voxnup Bot Manager v2)

Official Voxnup documentation Updated: Türkçe
In short

Bot commands are defined with this.command(name, options, handler) and used in chat as /botname:command (or this.prefix + command); /botname:yardim lists them automatically. For events, define methods such as onMessage and onReady, or use this.on("message", fn). Message, status, voice, moderation, storage, HTTP and timer methods live on this. Bot code runs in a sandbox with no file, OS or local network access.

Chat commands

Users type /botname:command arguments. If you set this.prefix = "!", !command works too. Handlers can be async. Commands not defined with this.command go to the onCommand(command, args, roomKey, channelKey, user) method.

OptionMeaning
description, usageShown in the automatic help list (/botname:yardim)
aliasesOther names, e.g. ["z"]
cooldownPer-user cooldown (seconds)
ownerOnlyOnly the owners in the .json file
minArgsFewer arguments returns "Usage: ..."
allow(ctx)Returning false rejects the command
hiddenHide from the help list

Slash commands

Give a command options (or slash: true) and the bot registers it in the / menu when it connects; users pick the command and fill in the options from pickers. The command reaches the bot as an interaction, not a message, and the same handler runs: ctx.isInteraction, ctx.options, ctx.get("user"), ctx.reply(text, { ephemeral: true }), ctx.defer(). The bot must reply or defer within 3 seconds; Bot Manager defers on its own after 2 seconds. Details: developer.voxnup.com. User side: Slash commands.

The handler receives ctx: command, args (a quoted phrase counts as one argument), rawArgs, user, roomKey, channelKey, message, reply(text).

Events

EventParameters / when
onReady{ reconnected, user }: when the connection and session are ready
onMessagetext, user, roomKey, channelKey, msg: messages that aren't commands (the bot's own messages are skipped)
onMessageEdited / onMessageDeletedmsg / { messageId, roomKey }
onSendFailed{ roomKey, reason, waitSeconds }: slow mode or timeout
onTyping{ roomKey, userKey, nickname }
onVoiceRoomJoin / onVoiceRoomLeaveroomKey, channelKey, user
onJoinedVoiceRoom, onJoinRoomFailed, onMoved, onKickedThe bot's own voice room events
onChannelJoin, onChannelUpdatedChannel events
onFriendRequest, onFriendAccepteduser
onGroupJoined, onGroupRemoved, onGroupMembersChanged, onGroupUpdated{ roomKey }
onPresence{ userKey, status, statusText, presence }
onServerError{ action, message }: the server rejected a request
onDisconnected / onReconnectedConnection lost / restored
onRawEventoperation, data, event: every event from the server
onErrorerror, where: every uncaught error
onStopWhen the bot is being stopped

Methods

GroupMethods
MessagessendMessage(text, roomKey) (Promise: { messageKey, roomKey }), sendDirectMessage(userKey, text), editMessage(messageKey, text, roomKey), deleteMessage(messageKey), startTyping(roomKey) / stopTyping(roomKey)
StatussetStatus(0..5), setPresence(text, { elapsed, iconUrl }), clearPresence()
Queries (Promise)getRoomUsers(roomKey), getOnlineFriends(), findUserVoiceRoom(userKey)
Voice and moderationjoinRoom / leaveRoom, moveUser(userKey, targetRoomKey), deafenUser(roomKey, userKey, on?), kickFromRoom(roomKey, userKey)
StoragegetState(key, file?), setState(key, value, saveNow?, file?), deleteState, stateKeys, clearStateFile, saveState
HTTPawait this.fetch(url, { method, headers, body, auth }) → { ok, status, headers, text, json, error }
TimerssetTimeout, setInterval, clearTimeout, clearInterval, this.every(ms, fn), this.after(ms, fn), this.cancel(id)
Note

Moderation only works in channel rooms: the bot's role needs the matching permission (Move Members, Deafen Members) and the bot must rank above its target. A bot can't send audio, and if it sits idle in a voice room it may count as inactive. Storage lives in states/<bot>/<file>.json and is saved once a minute and on shutdown.

Sandbox and limits

Setting (appsettings.json)DefaultNote
Sandbox.TimeoutMs5000Time limit for a single event handler; if exceeded the handler is stopped and the bot keeps running
Sandbox.MemoryLimitMb128
RateLimit5 messages per 5 sExtra messages are queued (up to 50), then dropped
Fetch.TimeoutSeconds / MaxResponseKb15 / 2048
Fetch.BlockPrivateNetworkstrueBots can't reach the local network (localhost, 192.168.x…)

Frequently asked questions

Why don't my bot's commands work?

Commands must be written as /botname:command (or with your prefix). The bot must be in that channel and have Send Messages there. Use bot status to check it's connected and bot logs <name> for errors.

Why does my bot get a "slow mode" error?

If slow mode is on in the room, the bot follows it too; onSendFailed fires with reason: "slow_mode" and the wait time. A bot also sends at most 5 messages per 5 seconds; the rest are queued.

Related guides

Still stuck? Email support@voxnup.com. Tell us which device and browser you use and include the exact error text you see, and we'll get back to you quickly.