Giter Site home page Giter Site logo

mericcan41 / discordjs-v14-template-ts Goto Github PK

View Code? Open in Web Editor NEW
177.0 2.0 58.0 33 KB

A typescript template for Discord.js v14 that includes handlers, slash commands, mongodb, permissions and more.

TypeScript 92.48% JavaScript 7.52%
discord discord-bot discord-bot-template discord-bots discord-js discord-js-v14 discord-js-v14-command-handler discord-js-v14-handler discordjs discordjs-bot discordjs-command-handling discordjs-v14 discord-js-template discordjs-typescript typescript discord-mongodb mongodb

discordjs-v14-template-ts's Introduction

Discord.js v14 Bot Template

Features

  • ๐ŸŸฆ Typescript
  • ๐Ÿ”ฅ Slash commands (supports auto complete!)
  • โœ‰๏ธ Message commands
  • ๐Ÿ•› Cooldowns
  • ๐Ÿด Detailed Permissions
  • ๐Ÿ’ช Event & Command handlers
  • ๐Ÿƒ MongoDB Support

Installation, Build and Run

  1. Clone the repository then create a file named .env and fill it out accordingly
TOKEN=YOURTOKENHERE
CLIENT_ID=BOTS CLIENT ID
PREFIX=!
MONGO_URI=YOUR MONGO CONNECTION STRING
MONGO_DATABASE_NAME=YOUR DATABASE NAME
  1. Install typescript, To install TypeScript, you can run the following command in your terminal, This will install the latest version of TypeScript globally on your computer. (You can skip this if you already have typescript installed)
npm install -g typescript
  1. Build the project by running the following command:

This command will also install the node modules if you haven't installed them.

npm run build
  1. Once the build is complete it will generated a folder named build that contains compiled version of your ts code to js. You can run the following command in your terminal to run the project:
npm start

discordjs-v14-template-ts's People

Contributors

bradyn1710 avatar davidotno avatar khouwdevin avatar mashwishi avatar mericcan41 avatar romadevworld avatar sertaykabuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

discordjs-v14-template-ts's Issues

[Error] error TS2339: Property 'send' does not exist on type 'TextChannel | DMChannel | PartialDMChannel | NewsChannel | StageChannel | PublicThreadChannel | PrivateThreadChannel | VoiceChannel'.

Building the typescript project has some type errors with the send command

src/commands/changePrefix.ts:8:45 - error TS2339: Property 'send' does not exist on type 'TextChannel | DMChannel | PartialDMChannel | NewsChannel | StageChannel | PublicThreadChannel | PrivateThreadChannel | VoiceChannel'.
  Property 'send' does not exist on type 'StageChannel'.

8         if (!prefix) return message.channel.send("No prefix provided")
                                              ~~~~

src/commands/changePrefix.ts:11:25 - error TS2339: Property 'send' does not exist on type 'TextChannel | DMChannel | PartialDMChannel | NewsChannel | StageChannel | PublicThreadChannel | PrivateThreadChannel | VoiceChannel'.
  Property 'send' does not exist on type 'StageChannel'.

11         message.channel.send("Prefix successfully changed!")
                           ~~~~

src/commands/greet.ts:8:21 - error TS2339: Property 'send' does not exist on type 'TextChannel | DMChannel | PartialDMChannel | NewsChannel | StageChannel | PublicThreadChannel | PrivateThreadChannel | VoiceChannel'.
  Property 'send' does not exist on type 'StageChannel'.

8     message.channel.send(
                      ~~~~

src/slashCommands/clear.ts:18:30 - error TS2339: Property 'messages' does not exist on type 'TextBasedChannel'.
  Property 'messages' does not exist on type 'StageChannel'.

18         interaction.channel?.messages.fetch({limit: messageCount})

src/slashCommands/clear.ts:21:64 - error TS2339: Property 'bulkDelete' does not exist on type 'TextChannel | NewsChannel | StageChannel | PublicThreadChannel | PrivateThreadChannel | VoiceChannel'.
  Property 'bulkDelete' does not exist on type 'StageChannel'.

21             const deletedMessages = await interaction.channel?.bulkDelete(msgs,true)

I'm not super well versed in typescript but this was my workaround:

const channel: TextChannel = interaction.channel as TextChannel;
    await channel?.send({
      content: `x`,
      files: [url],
    });
    return interaction.editReply('Successful');
  },

no build

node:internal/modules/cjs/loader:1078
throw err;
^

Error: Cannot find module '/Users/vuinishiusu/dev/bot/mini-pilar/build/index.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

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.