harmonyland / harmony Goto Github PK
View Code? Open in Web Editor NEWAn easy to use Discord API Library for Deno.
Home Page: https://harmony.mod.land
License: MIT License
An easy to use Discord API Library for Deno.
Home Page: https://harmony.mod.land
License: MIT License
Intents are kind of messed up for beginners, we need to mention a large Array of these, as of the test/index,ts, for a bot with both intents enabled:
client.connect(TOKEN, [
GatewayIntents.GUILD_MEMBERS,
GatewayIntents.GUILD_PRESENCES,
GatewayIntents.GUILD_MESSAGES,
GatewayIntents.DIRECT_MESSAGES,
GatewayIntents.DIRECT_MESSAGE_REACTIONS,
GatewayIntents.DIRECT_MESSAGE_TYPING,
GatewayIntents.GUILDS,
GatewayIntents.GUILD_BANS,
GatewayIntents.GUILD_EMOJIS,
GatewayIntents.GUILD_INTEGRATIONS,
GatewayIntents.GUILD_INVITES,
GatewayIntents.GUILD_MESSAGE_REACTIONS,
GatewayIntents.GUILD_MESSAGE_TYPING,
GatewayIntents.GUILD_VOICE_STATES,
GatewayIntents.GUILD_WEBHOOKS
])
This can be simplified by making some class with static properties like, Intents.All, Intents.Presence, Intents.ServerMembers, would be a lot helpful.
...and I'll look into doing this with my next PR 😄 If I'm wrong, please correct me.
What do you want to request?
before executing the command user can add custom methods
Do you have anything to tell us about your request?
execute(ctx: MyCustomContext) {
ctx.message.reply(`you have ${ctx.coin}coin`)
}
like this
What do you want to request?
Add arguments and a parser for them so that it will be easier to parse more complex arguments
in the way that akairo can do it.
I have made a small working version on a project already and I'm fine with implementing it
What's the bug?
Message.addReaction()
crashes with of http error 411 when sending an emoji.
How do we reproduce it?
use Message.addReaction("flushed")
(same if you specify ":flushed:").
What should have happened?
Instead of sending a reaction to the message, the it crashes deno completely.
What is actually happening?
PUT https://discord.com/api/v9/channels/*number*/messages/*another number*/reactions/flushed/@me returned 411
(unknown) undefined
throw new DiscordAPIError({
^
at BucketHandler.execute (https://deno.land/x/[email protected]/src/rest/bucket.ts:217:13)
at async BucketHandler.push (https://deno.land/x/[email protected]/src/rest/bucket.ts:51:14)
at async RESTManager.make (https://deno.land/x/[email protected]/src/rest/manager.ts:236:12)
at async RESTManager.put (https://deno.land/x/[email protected]/src/rest/manager.ts:339:12)
at async GuildTextChannel.addReaction (https://deno.land/x/[email protected]/src/structures/textChannel.ts:90:5)
What versions you're using?
Do you have anything to tell us more about the bug?
Mozilla docs say 411 means Length Required. I'm 90% sure i'm using the method right because this is a http error, not a TS or Deno error.
What do you want to request?
A few improvements with the arg parser:
false
if theres roles/users/channels with the same name so the bot dev can accurately send out an error message.What's the bug?
If you have the commandOwnerOnly event inside of an extension using decorators the ctx.guild field will be undefined
How do we reproduce it?
Code used to reproduce this bug
Comment out either line 32-34 or line 37, then run !test inside of a server and see what console logged
What should have happened?
ctx.guild should have returned the guild object in both cases
What is actually happening?
ctx.guild returns undefined inside of an extension and the guild object in the listener
What versions you're using?
Do you have anything to tell us more about the bug?
No
sticker support is needed
What's the bug?
Message#guild
is not populated if the source of the message is the payload of a messageDelete
event even if the deleted message comes from a guild. Message#guildID
is populated however.
How do we reproduce it?
messageDelete
event handlerconsole.log
both the message's guildID
and guild
What should have happened?
Both the guildID
and the guild
properties of the message
should not be undefined
.
What is actually happening?
guildID
is properly filled, but guild
is undefined
.
What versions you're using?
What do you want to request?
Adding unit tests
Do you have anything to tell us about your request?
Currently, harmony doesn't have any unit tests, which can make tests so much better and reliable.
What's the bug?
In the event messageUpdate
, if you grab the guild
from newMessage, it will return null.
How do we reproduce it?
if (!msg.member) return;
in messageUpdate
. Will return when msg is newMessage.What should have happened?
The member object would be returned.
What is actually happening?
We gain the ever growing collectors item called 'null'.
What versions you're using?
using the main branch
What do you want to request?
Add a try/catch
to these methods because it's really annoying to get your bot down when you do something wrong, or having an error but because you didn't put try/catch
, nothing is sent in the console.
Do you have anything to tell us about your request?
Almost every command handler does this!
You could also add an error
method in the command class (I think that it's weird to use the client to catch these).
Like the title says. Now that camel case is removed.
We can easily work on switching out eslint for deno lint
This will likely be done in v3 rather than in v2
What do you want to request?
Allow loading of extensions in the same way of loading commands
Do you have anything to tell us about your request?
nope
What question do you have?
How can I record voice of everyone on the voice channel? Is this functionality implemented or do I need to wait for implementation? And Harmony already supports audio libraries to make a music bot?
Thank you
Many class's constructors have Interfaces as parameters but since the Interface is not exported from mod.ts so they don't appear in the docs..
If someone, who is new to the library, will check the docs then he will go hella confused because we have many of these un-exported interfaces
Like this one class:
What do you want to request?
The ability to install from nest would be nice as alternative along side being able to install from /x/ and the GitHub repository itself.
Do you have anything to tell us about your request?
Nest provides a block-chain backed immutable registry for deno modules, adding support for it is as simple as creating an account and using their cli to link an api key and initialize a package file which contains information specifically for their registry and nothing else. An example of the package file it uses can be seen here on a package I'm working on currently that is using harmony itself as well.
What do you want to request?
Add the ability to use local file paths ie: ./pepega.png
inside of Embed images
Do you have anything to tell us about your request?
Don't believe so
What do you want to request?
Adding more examples
Do you have any solutions?
If you have, please tell us so we can add(or at least think about) your solution!
Since we have lots of bot codes in test/
, we might just need to change some and put them into the example.
Do you have anything to tell us about your request?
Right now harmony is getting known to many peoples and some junior coders can be confused if there are not enough examples.
What do you want to request?
Wake up fam new Discord features dropped
Docs:
Do you have any solutions?
Required changes:
resolved
is used for this as well. options
will always be an empty array.Do you have anything to tell us about your request?
go go power rangers
Thanks to @ZiomaleQ for giving us this list.
Currently, Harmony's license is an MIT license and copyright holder is Helloyunho.
But harmony-org owns the repository.
Therefore, how about putting the copyright holder under the harmony-org?
What do you want to request?
There is currently no way to retrieve the pins from a channel. The endpoints are implemented, but are not being used anywhere in the codebase.
Do you have any solutions?
Implement a fetchPins()
function on the TextChannel
class that allows fetching pins. I believe all text channels (including threads) allow pins, so this should be the correct place to implement them centrally.
Do you have anything to tell us about your request?
Not really, though I find it hard to believe that pins aren't currently accessible anywhere in the library...
What question do you have?
I'm following the example slash.ts
and I'm curious how do I delete all the slash commands of the bot?
message.guild?.commands.bulkEdit([{
name: 'ping',
description: "It's literally ping command. What did you expect?",
options: [{
name: 'pingarg',
description: 'Again literally pingArg',
required: false,
type: SlashCommandOptionType.STRING
}]
}])
It seems there is a bulkEdit()
method, is there a bulkDelete()
?
What do you want to request?
I would like to customize the classes in my CustomClient.
class CustomGuildManager extends GuildManager<GuildPayload, CustomGuild> {
// ...
}
class CustomClient extends Client<CustomEvent> {
guilds: CustomGuildManager = new CustomGuildManager(this);
// ...
}
Do you have any solutions?
Use Generic Type on classes to "BaseManager" or "HarmonyEventEmitter" for the client.
// On generic: "extends" or "="
export class GuildManager<T = GuildPayload, T2 = Guild> extends BaseManager<T, T2> {
// ...
}
Do you have anything to tell us about your request?
I can take care of it, if you approve the request.
Note: every sub module is supposed to have unit tests for everything that is testable on CI.
types
core
HTTPClient
RESTClient
(blocked by HTTPClient
)GatewayClient
ShardedClient
(blocked by RESTClient
)APIManager
(blocked by RESTClient and ShardedClient
)framework
ext
manual
There can be some sort of Cache Adapters which Client can use to handle caching. Those adapters can implement the basic methods we require for caching, like it can be similar to a Map with set, get, delete, and so on. In this way, there can even be persistent caching using something like Redis, just an adapter, which can be a class implementing an interface, will be needed.
Current decompression lib we use that is denoflate, has very high cpu usage on larger bot scale and it makes processing events slow. There is another zlib wasm package which works significantly better.
Bot on 2.2k Guilds
Denoflate
CPU Usage: 90-99%
Time taken for ready
: 200s
Zlib Wasm
CPU Usage: 20-27%
Time taken for ready
: 30s
What do you want to request?
When doing commands like so:
class PingCommand extends Command {
name = "ping";
}
To allow for name
to be static, so it can be accesed using: PingCommand.name
.
Do you have anything to tell us about your request?
This is useful in a few cases, in my case I'm trying to automatically generate a help command without making a instance of every command everytime the help command is called.
What's the bug?
According to the Discord API docs, ThreadChannel
s should have access to the id of the user who created the thread as the field owner_id
(repurposed from group DM channels) along with the slowmode setting of the thread (rate_limit_per_user
), however harmony doesn't appear to expose these field in any way and they are not included in the lower-level ThreadChannelPayload
interface either.
Debug Log : https://pastebin.com/ucJSYsbN (Only after limit<10), https://pastebin.com/3LshT4Ds (Full log from console)
When bot starts once, then session will resets after 24 hours.
And when session resets, bot will start to cause error and keep reconnect to reach session limit.
I can't find what's first error from console because its log was too long and exceeds console limit.
Only remain codes are two : 1000, 4005
#27 (comment)
After looking at this I also saw there wasn't any GitHub Actions to actively enforce style on PRs, pushes, etc. and I think you should setup one.
If you need an example I can post one.
types
core
HTTPClient
RESTClient
(blocked by HTTPClient
and types)GatewayClient
(blocked by types)ShardedClient
(blocked by GatewayClient
)APIManager
(blocked by RESTClient and ShardedClient
)framework
Client
ext
manual
The title should explain everything
We should strive to get as much types known and if necesarry use unknown
This will allow us to find type error's and bug related to typeErrors alot easier
What question do you have?
Why is this error occurring? Have I done something wrong?
/*
deps.ts
*/
import { Client, Message} from 'https://deno.land/x/harmony/mod.ts';
then I run deno cache
error: TS2367 [ERROR]: This condition will always return 'false' since the types 'SlashCommandOptionType' and '0' have no overlap.
type === 0 || type === 1
~~~~~~~~~~
at https://deno.land/x/[email protected]/src/interactions/slashCommand.ts:117:7
How do we reproduce it?
// SlashCommandHandlerCallback of previously created slash command
async function handle(interaction: SlashCommandInteraction) {
await interaction.reply("reply")
interaction.send("followup") // 💀
}
What should have happened?
A followup message with the string as content should be sent.
What is actually happening?
error: Uncaught (in promise) TypeError: Cannot read property 'components' of undefined
(option as WebhookMessageOptions).components === undefined
^
at SlashCommandInteraction.send (https://raw.githubusercontent.com/harmonyland/harmony/main/src/structures/interactions.ts:314:43)
What versions you're using?
What's the bug?
Hi!
I try to react with an emoji but I get an error that is way too strange to not be a bug.
My code :
[imports]
const WAIT_EMOJI = '813551205283790889';
const LABS_TS = '507389389098188820';
class MyCommand extends Command {
[...]
public async execute(ctx: CommandContext): Promise<void> {
ctx.message.addReaction(await ctx.client.emojis.fetch(LABS_TS, WAIT_EMOJI));
}
}
The error :
error: Uncaught (in promise) DiscordAPIError: {
url: "https://discord.com/api/v8/channels/620663106250604546/messages/818225520994549840/reactions/%3Ca:wa...",
status: 400,
method: "PUT",
code: 50035,
message: "Invalid Form Body",
errors: {
emoji_id: [
{
code: "NUMBER_TYPE_COERCE",
message: 'Value "813551205283790889>" is not snowflake.'
}
]
},
requestData: {
headers: {
"User-Agent": "DiscordBot (harmony, https://github.com/harmony-org/harmony)",
Authorization: "Bot ODAxOTc0NTIxMTMzMjY5MDUz.YAoe-Q.is9H6QQgGmxMIyBdS3YB5PWCTF8"
},
body: undefined,
method: "PUT"
}
}
reject(new DiscordAPIError(Deno.inspect(error), error))
^
at RESTManager.handleStatusCode (https://deno.land/x/[email protected]/src/models/rest.ts:500:14)
at Object.onComplete (https://deno.land/x/[email protected]/src/models/rest.ts:577:22)
at async https://deno.land/x/[email protected]/src/models/rest.ts:249:30
Process finished with exit code 1
What should have happened?
Fetch the emoji and react with it.
What is actually happening?
Crash because it searched the emoji with the ID + >
, and the link strangely finish with <a:wa
, but the emoji is <a:wait:813551205283790889>
.
What versions you're using?
Do you have anything to tell us more about the bug?
This should be better documented, with typedoc for example.
https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
What's the bug?
In the event messageUpdate
, if you grab the guild
from newMessage, it will return null.
How do we reproduce it?
if (!msg.guild) return;
in messageUpdate
. Will return when msg is newMessage.if (!msg.guildID) return;
in messageUpdate
. WIll not return when msg is newMessage.What should have happened?
The guild object would be returned.
What is actually happening?
We gain the ever growing collectors item called 'null'.
What versions you're using?
What's the bug?
When requesting GET API endpoints, Harmony tries to send the parameters in the body, but GET requests can't have a body.
How do we reproduce it?
For example, this error occurs when trying to fetch messages of a text channel (calling fetchMessages
on a TextChannel
)
What should have happened?
Instead of trying to send a GET request with a body, GET parameters should be used.
What versions you're using?
Do you have anything to tell us more about the bug?
Relevant stacktrace:
error: Uncaught (in promise) TypeError: HEAD and GET requests may not have a body.
throw new HTTPError(
^
at BucketHandler.execute (https://deno.land/x/[email protected]/src/rest/bucket.ts:133:15)
at async BucketHandler.execute (https://deno.land/x/[email protected]/src/rest/bucket.ts:143:14)
at async BucketHandler.push (https://deno.land/x/[email protected]/src/rest/bucket.ts:51:14)
at async RESTManager.make (https://deno.land/x/[email protected]/src/rest/manager.ts:236:12)
at async RESTManager.get (https://deno.land/x/[email protected]/src/rest/manager.ts:259:12)
at async Proxy.<anonymous> (https://deno.land/x/[email protected]/src/rest/manager.ts:47:11)
at async GuildTextChannel.fetchMessages (https://deno.land/x/[email protected]/src/structures/textChannel.ts:141:19)
Message.author is always User and informations are reduced.
Message.author should be User | Member
for short codes.
I get this error when trying the ping-example:
$ deno run --allow-net ping.ts
harmony - ping example
Input Bot Token: <token removed by hand>
Input Intents (0 = All, 1 = Presence, 2 = Server Members, 3 = None): 0
error: Uncaught (in promise) TypeError: Cannot read property 'remaining' of undefined
if (info.session_start_limit.remaining === 0)
^
at Gateway.sendIdentify (index.ts:198:36)
at async Gateway.onmessage (index.ts:88:11)
I am not sure, if I do something wrong but it looks like the error is not on my side.
Slash commands will be added to the API at December 15th.
I think it should support Slash command gateway events and way to add slash commands for global or each guilds.
What do you want to request?
Like commands, allow for dynamic loading of listeners
The implementation should be doable enough and it could possibly re-use code
Do you have anything to tell us about your request?
I can implement it after I finished up with #134
What's the bug?
Few types and structures exported from deploy.ts are missing from the actual source.
How do we reproduce it?
import * as slash from "https://raw.githubusercontent.com/harmonyland/harmony/main/deploy.ts";
deno cache --unstable file.ts
What is actually happening?
Download https://raw.githubusercontent.com/harmonyland/harmony/main/src/types/messageComponents.ts
Download https://raw.githubusercontent.com/harmonyland/harmony/main/src/structures/messageComponents.ts
error: Import 'https://raw.githubusercontent.com/harmonyland/harmony/main/src/types/messageComponents.ts' failed: 404 Not Found
at https://raw.githubusercontent.com/harmonyland/harmony/main/deploy.ts:149:0
What do you want to request?
A onMissingArgs(ctx: CommandContext)
function in Command
when using CommandClient
, this would be equivalent to client.on("commandMissingArgs", (ctx: CommandContext) => {})
Do you have anything to tell us about your request?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.