Giter VIP home page Giter VIP logo

officer-beepsky's Introduction

Officer Beepsky

Officer-Beepsky is a Discord bot made using:

Building

To build you need the JDK, AdoptOpenJDK or Oracle's JDK should both work fine, however AdoptOpenJDK 17 is what I will be using and what is used for CI Builds. Optionally you may also want to install Intellij IDEA Community.

The easiest way to build is using ./gradlew jar in either PowerShell (Windows), or in the terminal (Linux/Mac).

You could alternatively use Intellij and select jar from Gradle Tasks->Build->jar, and once you've done this step you can simply build by pressing the green run arrow at the top.

The jar will built so that all dependencies will be packed into it in order to make it easily portable.

Running

You can run it from the terminal/PowerShell by typing java -jar Officer-Beepsky-x.x.x.jar <Discord token> <Owner ID>.

Build, run, and update script

Optionally you can use the following script to build, run, and update the bot when needed.

Linux/Mac:

curl https://raw.githubusercontent.com/CorruptComputer/Officer-Beepsky/master/run.sh -o run.sh
bash run.sh

Windows: (PowerShell)

Invoke-WebRequest https://raw.githubusercontent.com/CorruptComputer/Officer-Beepsky/master/run.ps1 -OutFile run.ps1
./run.ps1

And when its time to update just private message the bot restart and it will update and restart! WARNING: The restart command will only shut it down if you do not use the script.

Contributing

This project follows the Google Java Style Guide. You can add the style to your Intellij by using this and this guide.

You can check if your code is good by using the checkstyleMain gradle task:

./gradlew checkstyleMain

The generated JavaDocs can be found here.

officer-beepsky's People

Contributors

corruptcomputer avatar fmmmlee avatar gradle-update-robot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fmmmlee 3neb

officer-beepsky's Issues

Transition to non-blocking

Any .block() can be moved to be .subscribe() in order to make it asynchronous. This will require modifying many aspects of how the code operates.

Crash when sending a message to a channel where the bot has no access

[events-197] ERROR reactor.core.scheduler.Schedulers - Scheduler worker in group main failed with an uncaught exception
reactor.core.Exceptions$ErrorCallbackNotImplemented: ClientException{request=ClientRequest{method=POST, url='/channels/129145765049139200/messages', headers=DefaultHttpHeaders[content-type: application/json]}, status=403 Forbidden, headers=DefaultHttpHeaders[Date: Tue, 16 Apr 2019 23:35:18 GMT, Content-Type: application/json, Content-Length: 44, Connection:keep-alive, Set-Cookie: __cfduid=d09f1d8b4030693a73a3f65e47dac8fd51555457718; expires=Wed, 15-Apr-20 23:35:18 GMT; path=/; domain=.discordapp.com; HttpOnly, Strict-Transport-Security: max-age=31536000; includeSubDomains, X-RateLimit-Limit:5, X-RateLimit-Remaining: 4, X-RateLimit-Reset: 1555457724, Via: 1.1 google, Alt-Svc: clear, Expect-CT: max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct", Server: cloudflare, CF-RAY: 4c89f9935cbb9b81-DFW], errorResponse=ErrorResponse{fields={code=50001, message=Missing Access}}}                          

Caused by: ClientException{request=ClientRequest{method=POST, url='/channels/129145765049139200/messages', headers=DefaultHttpHeaders[content-type: application/json]}, status=403 Forbidden, headers=DefaultHttpHeaders[Date: Tue, 16 Apr 201923:35:18 GMT, Content-Type: application/json, Content-Length: 44, Connection: keep-alive, Set-Cookie: __cfduid=d09f1d8b4030693a73a3f65e47dac8fd51555457718; expires=Wed, 15-Apr-20 23:35:18 GMT; path=/; domain=.discordapp.com; HttpOnly, Strict-Transport-Security: max-age=31536000; includeSubDomains, X-RateLimit-Limit: 5, X-RateLimit-Remaining: 4, X-RateLimit-Reset: 1555457724, Via: 1.1 google, Alt-Svc: clear, Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct", Server: cloudflare, CF-RAY: 4c89f9935cbb9b81-DFW], errorResponse=ErrorResponse{fields={code=50001, message=Missing Access}}}                                                        at discord4j.rest.http.client.DiscordWebClient.clientException(DiscordWebClient.java:144)
        at discord4j.rest.http.client.DiscordWebClient.lambda$null$7(DiscordWebClient.java:122)                                                                                                                                                       at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118)
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)                                                                                                                                                 at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1505)
        at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:241)                                                                                                                                                               at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)                                                                                                                                              at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:113)                                                                                                                                                             at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287)                                                                                                                                   at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.FluxUsing$UsingFuseableSubscriber.onNext(FluxUsing.java:350)                                                                                                                                                        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onNext(FluxFilterFuseable.java:113)
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:486)
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1505)
        at reactor.core.publisher.MonoReduceSeed$ReduceSeedSubscriber.onComplete(MonoReduceSeed.java:156)
        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:363)
        at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136)
        at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:372)
        at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:196)
        at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:337)
        at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:333)
        at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:382)
        at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:522)
        at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:141)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
        at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1476)
        at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1225)
        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1272)
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
        at java.lang.Thread.run(Thread.java:748)
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
        reactor.core.publisher.Mono.flatMap(Mono.java:2490)
        discord4j.rest.http.client.DiscordWebClient.lambda$null$10(DiscordWebClient.java:122)
Error has been observed by the following operator(s):
        |_      Mono.flatMap ⇢ discord4j.rest.http.client.DiscordWebClient.lambda$null$10(DiscordWebClient.java:122)
        |_      Mono.switchIfEmpty ⇢ discord4j.rest.http.client.DiscordWebClient.lambda$null$10(DiscordWebClient.java:123)
        |_      Mono.doFinally ⇢ reactor.netty.http.client.HttpClientFinalizer.lambda$responseSingle$7(HttpClientFinalizer.java:97)
        |_      Mono.flatMap ⇢ reactor.netty.http.client.HttpClientFinalizer.responseSingle(HttpClientFinalizer.java:95)
        |_      Mono.flatMap ⇢ discord4j.rest.http.client.DiscordWebClient.exchange(DiscordWebClient.java:111)
        |_      Mono.flatMap ⇢ discord4j.rest.request.RequestStream$Reader.accept(RequestStream.java:208)
        |_      Flux.concatMap ⇢ reactor.retry.DefaultRetry.apply(DefaultRetry.java:115)
        |_      Mono.retryWhen ⇢ discord4j.rest.request.RequestStream$Reader.accept(RequestStream.java:209)
        |_      Flux.concatMap ⇢ reactor.retry.DefaultRetry.apply(DefaultRetry.java:115)
        |_      Mono.retryWhen ⇢ discord4j.rest.request.RequestStream$Reader.accept(RequestStream.java:210)
        |_      Mono.log ⇢ discord4j.rest.request.RequestStream$Reader.accept(RequestStream.java:211)
        |_      Mono.doFinally ⇢ discord4j.rest.request.RequestStream$Reader.accept(RequestStream.java:212)
        |_      Mono.flatMap ⇢ discord4j.rest.request.DefaultRouter.exchange(DefaultRouter.java:80)
        |_      Mono.publishOn ⇢ discord4j.rest.request.DefaultRouter.exchange(DefaultRouter.java:89)
        |_      Mono.map ⇢ discord4j.core.object.entity.BaseMessageChannel.createMessage(BaseMessageChannel.java:74)
        |_      Mono.map ⇢ discord4j.core.object.entity.BaseMessageChannel.createMessage(BaseMessageChannel.java:75)

        Suppressed: java.lang.Exception: #block terminated with an error
                at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:93)
                at reactor.core.publisher.Mono.block(Mono.java:1494)
                at xyz.gupton.nickolas.beepsky.BotUtils.sendMessage(BotUtils.java:51)
                at xyz.gupton.nickolas.beepsky.BotUtils.sendMessage(BotUtils.java:33)
                at xyz.gupton.nickolas.beepsky.owner.commands.AnnouncementCommand.execute(AnnouncementCommand.java:44)
                at xyz.gupton.nickolas.beepsky.CommandHandler.onMessageReceived(CommandHandler.java:34)
                at reactor.core.publisher.LambdaSubscriber.onNext(LambdaSubscriber.java:130)
                at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
                at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)
                at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
                at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
                at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:353)
                at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.tryOnNext(FluxFilterFuseable.java:143)
                at reactor.core.publisher.FluxOnAssembly$OnAssemblyConditionalSubscriber.tryOnNext(FluxOnAssembly.java:472)
                at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.runAsync(FluxPublishOn.java:866)
                at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.run(FluxPublishOn.java:939)
                at reactor.scheduler.forkjoin.ForkJoinPoolScheduler$DisposableWorkerTask.run(ForkJoinPoolScheduler.java:443)
                at reactor.scheduler.forkjoin.ForkJoinPoolScheduler$Worker.processTaskQueue(ForkJoinPoolScheduler.java:407)
                at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
                at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
                at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
                at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
                at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Cleanup error output's in the console

Discord4j throws a lot of exceptions in some cases, however most of these do not cause any crashes or ill effects.

This one can be ignored:

[udp-nio-1] WARN io.netty.util.ReferenceCountUtil - Failed to release a message: DatagramPacket(/104.153.87.134:50334 => /10.70.99.16:44868, PooledUnsafeDirectByteBuf(freed))
io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at io.netty.buffer.AbstractReferenceCountedByteBuf.toLiveRealCnt(AbstractReferenceCountedByteBuf.java:190)
        at io.netty.buffer.AbstractReferenceCountedByteBuf.release0(AbstractReferenceCountedByteBuf.java:142)
        at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:133)
        at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88)
        at io.netty.channel.DefaultAddressedEnvelope.release(DefaultAddressedEnvelope.java:101)
        at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88)
        at io.netty.util.ReferenceCountUtil.safeRelease(ReferenceCountUtil.java:113)
        at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:166)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
        at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
        at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:93)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)

As it is being tracked upstream as Discord4J/Discord4J#495

Colors on commands disappeared when upgrading to v3 of Discord4j

They all just need changed to have a Color set at the end of the BotUtils.sendMessage() method call. Green for command sucessful, red otherwise. Colors can already be found in the 8ball command.

  • HelpCommand #9
  • EightBallCommand
  • NameColorCommand #8
  • QueueCommand #9
  • ListQueueCommand #9
  • SkipCommand #9
  • StopCommand #9
  • TimeSetCommand #9
  • VolumeCommand #9

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.