GithubHelp home page GithubHelp logo

donovandmc / oceanic Goto Github PK

View Code? Open in Web Editor NEW
236.0 2.0 20.0 13.27 MB

A NodeJS library for interfacing with Discord.

Home Page: https://oceanic.ws

License: MIT License

JavaScript 1.16% TypeScript 98.84%
discord nodejs hacktoberfest javascript

oceanic's Introduction


const { Client } = require("oceanic.js");
const client = new Client({ auth: "Bot [TOKEN]" });

client.on("ready", async() => {
    console.log("Ready as", client.user.tag);
});

// if you do not add a listener for the error event, any errors will cause an UncaughtError to be thrown,
// and your process may be killed as a result.
client.on("error", (err) => {
    console.error("Something Broke!", err);
});

client.connect();

For more examples, see the examples folder on GitHub.


Installation

NodeJS 18.13.0 or higher is required.

See Development Builds if you wish to install in-dev versions.

npm i oceanic.js --omit=optional

If you need voice support, add --include=optional. Voice support is currently provided by @discordjs/voice.

See the examples folder on GitHub for some examples, and visit this site for documentation.

Development Builds

npm i oceanic.js@dev

The documentation under dev is always for the latest commit. If something isn't working that's in the documentation, you're likely looking at the wrong documentation.


Optional Dependencies

  • pako - Compression (gateway)
  • zlib-sync - Compression (gateway, faster than pako)
  • erlpack - Encoding (gateway, alternative to JSON)

Links

oceanic's People

Contributors

donovandmc avatar nuckyz avatar dependabot[bot] avatar coolcalcacol avatar ray-1337 avatar theessem avatar snazzah avatar mtripg6666tdr avatar thekodetoad avatar charmants avatar urbainn avatar davidffa avatar doomestee avatar infinixius avatar thefallenspirit avatar reinacchi avatar vendicated avatar

Stargazers

UpperCtrl avatar João Chung avatar Muhammad Ilham Jaya  avatar amber avatar Muhammad Harun Alrasyid avatar Ayuka avatar  avatar Zeleff_ avatar  avatar  avatar Jerry avatar Dominik Hautau avatar A$AP ROCKO avatar Keith H avatar Rui avatar Kris avatar yosoof avatar Vinicius avatar rini avatar David Hayes avatar Junior avatar GZod01 avatar Timothy Zwart avatar Tejas Shettigar  avatar Xmaster avatar Tristan Rechenberger avatar  avatar MrlolDev avatar Meriem SOUBIH avatar Prahalad Belavadi avatar Kira Kitsune avatar André Lucas avatar clockcrockwork avatar Debanjan Das avatar H2GG avatar  avatar  avatar name avatar Leonardo Araujo avatar ROG avatar Kainoa Kanter avatar LonelyDeathVGX avatar  avatar T.F.A avatar Max Fisher avatar Ayush avatar zxc-psycho avatar  avatar Alexandr Virgovič avatar Julio Reyes avatar Drake avatar humblefool13.dev avatar Grzegorz Szwyngiel avatar Syswraith avatar Sahith Nallapareddy avatar Eros avatar sadek avatar  avatar Eddy avatar JustEvil avatar Tim Smith avatar taira avatar shadowplay1 avatar Dagermohamed avatar seryuroot avatar Juanda avatar Mustafa Can avatar  avatar  avatar beeman avatar rjt avatar Atheal avatar Dan avatar Stroos avatar Chris avatar Codeway avatar Simon avatar Luís Felipe avatar  avatar Alexander J. Rodriguez D. avatar Fyphen avatar  avatar Anjelo Go avatar Nopox avatar Luna avatar ArttX avatar haiku avatar  avatar Rat avatar Palm avatar Krystian Postek avatar Alex avatar Arda Berk avatar ZixeSea avatar ahmed avatar  avatar Andrejs Agejevs avatar lasse avatar Oshyyyyyyyyyyyy avatar Masanori Ogino avatar

Watchers

 avatar Kostas Georgiou avatar

oceanic's Issues

is it working with accounts?

            throw new TypeError("Failed to get gateway information.", { cause: err });```

copy paste the example cod and but the token and nothing

"data.map is not a function" when using REST/Channels.getPollAnswerUsers method

Hello 👋
While I was testing the version 1.10.0 to see which users voted the answers from a poll, I used this code

const data = await client.rest.channels.getPollAnswerUsers(
  "CHANNEL_ID",
  "MESSAGE_ID",
  1
);

But when I was executing that code, I saw this error

TypeError: data.map is not a function

I did a custom request to see what was the response, so I used this code

const data = await client.rest.authRequest({
  method: "GET",
  path: "/channels/CHANNEL_ID/polls/MESSAGE_ID/answers/1",
});
{
  users: [
    // Discord API User Objects
  ]
}

So, from this line

const users = data.map(user => this.#manager.client.users.update(user));

I think it should be changed to this due to response body being an object with an array of users inside

const users = data.users.map(user => this.#manager.client.users.update(user));

Thanks for reading

Unable to nullify content when editing a message or an interaction response

Current Behaviour:

When attempting to edit the original reply to an interaction using CommandInteraction.editOriginal(), the content field of InteractionContent must be of type string or undefined.

This field is inherited from the InteractionContent interface, which extends ExecuteWebhookOptions, which extends CreateMessageOptions.

According to https://discord.com/developers/docs/resources/channel#edit-message "All parameters to this endpoint are optional and nullable.". When nulling the content field, Discord will remove the content from the original message.

Expected Behaviour:

Allowed to pass null as content when editing a message or interaction, to remove content from the message. This is useful when deferring an interaction, and editing the original response to be an embed or an attachment.

Additional Info:

Version: 1.10.0

Random error from Oceanic.js

/home/container/node_modules/oceanic.js/dist/lib/structures/Message.js:125
        if (data.attachments.length !== 0) {
                             ^

TypeError: Cannot read properties of undefined (reading 'length')
    at new Message (/home/container/node_modules/oceanic.js/dist/lib/structures/Message.js:125:30)
    at TypedCollection.update (/home/container/node_modules/oceanic.js/dist/lib/util/TypedCollection.js:54:29)
    at Shard.onDispatch (/home/container/node_modules/oceanic.js/dist/lib/gateway/Shard.js:715:52)
    at Shard.onPacket (/home/container/node_modules/oceanic.js/dist/lib/gateway/Shard.js:1055:27)
    at Shard.onWSMessage (/home/container/node_modules/oceanic.js/dist/lib/gateway/Shard.js:1243:29)
    at WebSocket.emit (node:events:513:28)
    at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1184:20)
    at Receiver.emit (node:events:513:28)
    at Receiver.dataMessage (/home/container/node_modules/ws/lib/receiver.js:541:14)
    at Receiver.getData (/home/container/node_modules/ws/lib/receiver.js:459:17)

Node.js v19.9.0

Using Oceanic 1.7.1
It's erroring very randomly but often.

SequentialBucket can get stuck processing the queue

See esmBot/esmBot#383. There's a chance that a SequentialBucket instance can have the processing value set to true and never be reset to false, causing all requests sent to an attached endpoint to never be sent. I haven't checked the queue itself in the SequentialBucket since it's private, but it's probably worth looking to see if it gets hung up somehow.

Add es-419

Quite useless and no one cares, but it would be nice

Announcement/public thread channels can sometimes cause GUILD_CREATE handler to fail

I occasionally see this error pop up in logs when starting my bot. Running it standalone results in a crash, but running it in PM2 causes it to keep running after this:

TypeError: Cannot read properties of undefined (reading 'archive_timestamp')
    at new ThreadChannel (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/structures/ThreadChannel.js:46:61)
    at new AnnouncementThreadChannel (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/structures/AnnouncementThreadChannel.js:9:9)
    at Map.update (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/util/TypedCollection.js:54:29)
    at new Guild (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/structures/Guild.js:214:37)
    at Map.update (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/util/TypedCollection.js:54:29)
    at Shard.createGuild (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/gateway/Shard.js:146:42)
    at Shard.onDispatch (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/gateway/Shard.js:300:40)
    at Shard.onPacket (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/gateway/Shard.js:1044:27)
    at Shard.onWSMessage (/home/esmBot/esmBot/node_modules/.pnpm/[email protected][email protected]/node_modules/oceanic.js/dist/lib/gateway/Shard.js:1229:29)
    at WebSocket.emit (node:events:513:28)

Since it seems to mostly occur on startup before the ready event, I'd imagine that it might be due to some missing/uncached data. After some attempts to debug the issue, it seems like a PublicThreadChannel is being passed into the data field of the ThreadChannel constructor. Will keep looking into this.

Process errors when trying to access CommandInteraction#guild when app is not installed in that guild

Current Behaviour:

When attempting to access CommandInteraction#guild, if the app is not installed in that guild, you will receive the following error:

UncachedError: CommandInteraction#guild is not present if you don't have the GUILDS intent.

This error is even received when simply logging the interaction console.log(interaction).

Expected Behaviour:

CommandInteraction#guild will be null and will not error when the app is not installed and the current context is 0 (Guild).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.