Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Michael55555/dbc
Browse files Browse the repository at this point in the history
  • Loading branch information
m5x5 committed Oct 1, 2021
2 parents 36544fd + 9c2931d commit 80d9e5a
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 33 deletions.
43 changes: 11 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
<p align="center"><img src="https://i.imgur.com/X7dSE68.png"></p>
Welcome to Discord Bot Creator, a free open source discord bot creator which is much more powerful than the alternatives.
Currently it's still in development but you can check out the early version using the commands below. Also feel free to join us on [Discord](https://discord.gg/Z7ybzt2KRr).

## Usage

### Create an App

```
# with npx
$ npx create-nextron-app my-app --example with-javascript
# with yarn
$ yarn create nextron-app my-app --example with-javascript
# with pnpx
$ pnpx create-nextron-app my-app --example with-javascript
```
## Prerequisites
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Node.js](https://nodejs.org/en/download/)

### Install Dependencies

```
$ cd my-app
# using yarn or npm
$ yarn (or `npm install`)
# using pnpm
$ pnpm install --shamefully-hoist
```
## Usage

### Use it
### Get started

```
# development mode
$ yarn dev (or `npm run dev` or `pnpm run dev`)
# production build
$ yarn build (or `npm run build` or `pnpm run build`)
$ git clone git@github.com:Michael55555/dbc.git
$ cd dbc
$ npm install
$ npm run dev
```
78 changes: 77 additions & 1 deletion renderer/components/dashboard/DashboardContext.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,83 @@
import { ipcRenderer } from "electron";
<<<<<<< Updated upstream:renderer/components/dashboard/DashboardContext.js
import { createContext, useContext, useEffect, useState } from "react";
=======
import {
Context,
createContext,
PropsWithChildren,
useContext,
useEffect,
useState,
} from "react";
>>>>>>> Stashed changes:renderer/components/dashboard/DashboardContext.tsx
import useActions from "../../lib/useActions";
import useCommands from "../../lib/useCommands";
import useEvents from "../../lib/useEvents";
import useSettings from "../../lib/useSettings";
import { useModeContext } from "./ModeContext";

<<<<<<< Updated upstream:renderer/components/dashboard/DashboardContext.js
const DashboardContext = createContext(null);
=======
type Action = {
name: string;
};

type Handler = {
name: string;
actions: Action[];
};

type Dashboard = {
events?: Handler[];
commands?: Handler[];
actionSchemas: [];
actionModalVisible: boolean;
handlerIndex: number;
actionIndex: number;
errors: any[];
handlers?: Handler[];
actionSchema?: any;
};
type ReorderAction = (from: number, to: number) => void;
type UpdateHandlerIndex = (index: number) => void;
type RemoveAction = (index: number) => void;
type AddHandler = (handler?: Handler) => void;

type Functions = {
reorderAction?: ReorderAction;
updateHandlerIndex?: UpdateHandlerIndex;
removeAction?: RemoveAction;
addHandler?: AddHandler;
};

type DashboardContextValue = Dashboard & Functions;

export const DashboardContext = createContext(
{}
) as Context<DashboardContextValue>;
>>>>>>> Stashed changes:renderer/components/dashboard/DashboardContext.tsx

export function useDashboardContext() {
return useContext(DashboardContext);
return useContext<DashboardContextValue>(DashboardContext);
}

export function DashboardProvider({ children }) {
const [actionSchemas] = useActions();
let [events, setEvents] = useEvents();
let [commands, setCommands] = useCommands();
const [settings] = useSettings();
const [mode] = useModeContext();

<<<<<<< Updated upstream:renderer/components/dashboard/DashboardContext.js
const [state, setState] = useState({
actionSchemas: actionSchemas,
mode: "command",
=======
const [state, setState] = useState<Dashboard>({
actionSchemas,
>>>>>>> Stashed changes:renderer/components/dashboard/DashboardContext.tsx
actionModalVisible: false,
commands,
events,
Expand Down Expand Up @@ -60,14 +118,21 @@ export function DashboardProvider({ children }) {
setState({ ...state, actionSchemas });
}, [JSON.stringify(actionSchemas)]);

<<<<<<< Updated upstream:renderer/components/dashboard/DashboardContext.js
const handlers =
(state.mode === "event" ? state.events : state.commands) || [];
const handler = handlers[state.handlerIndex] || {};
const actions = handler.actions || [];
=======
const handlers = (mode === "event" ? state.events : state.commands) || [];
const handler = handlers[state.handlerIndex] || { actions: [] };
const actions = handler.actions;
>>>>>>> Stashed changes:renderer/components/dashboard/DashboardContext.tsx
const action = actions[state.actionIndex] || {};
const actionSchema =
actionSchemas?.find(({ name }) => action.name === name) || {};

<<<<<<< Updated upstream:renderer/components/dashboard/DashboardContext.js
/**
* @param {string} mode
*/
Expand All @@ -81,6 +146,10 @@ export function DashboardProvider({ children }) {
*/
const updateHandlerIndex = (index) => {
let newIndex;
=======
const updateHandlerIndex: UpdateHandlerIndex = (index) => {
let newIndex: number;
>>>>>>> Stashed changes:renderer/components/dashboard/DashboardContext.tsx

if (handlers[index]) {
newIndex = index;
Expand Down Expand Up @@ -241,6 +310,7 @@ export function DashboardProvider({ children }) {
actions: actions,
action,
...state,
<<<<<<< Updated upstream:renderer/components/dashboard/DashboardContext.js
updateMode,
hideActionModal,
showActionModal,
Expand All @@ -253,6 +323,12 @@ export function DashboardProvider({ children }) {
updateAction,
updateActionIndex,
reorderAction,
=======
reorderAction,
updateHandlerIndex,
removeAction,
addHandler,
>>>>>>> Stashed changes:renderer/components/dashboard/DashboardContext.tsx
actionSchema,
}}
>
Expand Down
Loading

0 comments on commit 80d9e5a

Please sign in to comment.