diff --git a/src/webpage/bot.ts b/src/webpage/bot.ts index eb0fd89..e83154f 100644 --- a/src/webpage/bot.ts +++ b/src/webpage/bot.ts @@ -1,9 +1,11 @@ import { mainuserjson } from "./jsontypes.js"; import { Localuser } from "./localuser.js"; import { MarkDown } from "./markdown.js"; -import { Settings } from "./settings.js"; +import { Form, Settings } from "./settings.js"; import { User } from "./user.js"; import {guildjson} from "./jsontypes.js"; +import { PermissionToggle } from "./role.js"; +import { Permissions } from "./permissions.js"; class Bot{ readonly owner:Localuser; readonly token:string; @@ -247,5 +249,29 @@ class Bot{ body: JSON.stringify(json), }); } + static InviteMaker(id:string,container:Form,info:Localuser["info"]){ + const gen=container.addSubOptions("URL generator",{ + noSubmit:true + }); + const params = new URLSearchParams(""); + params.set("instance", info.wellknown); + params.set("client_id", id); + params.set("scope", "bot"); + const url=gen.addText(""); + const perms=new Permissions("0"); + for(const perm of Permissions.info){ + const permsisions=new PermissionToggle(perm,perms,gen); + gen.options.push(permsisions); + gen.generate(permsisions); + } + const cancel=setInterval(()=>{ + if(!gen.container.deref()){ + clearInterval(cancel); + } + params.set("permissions",perms.allow.toString()); + const encoded = params.toString(); + url.setText(`${location.origin}/oauth2/authorize?${encoded}`); + },100) + } } export {Bot}; diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 36f7c7c..5739fab 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -1474,6 +1474,9 @@ class Localuser{ const botc=new Bot(bot,token,this); botc.settings(); } + }); + form.addButtonInput("","Bot Invite Creator",()=>{ + Bot.InviteMaker(appId,form,this.info); }) } //---------- resolving members code ----------- diff --git a/src/webpage/permissions.ts b/src/webpage/permissions.ts index 678b1ba..483e207 100644 --- a/src/webpage/permissions.ts +++ b/src/webpage/permissions.ts @@ -296,6 +296,9 @@ class Permissions{ } } getPermission(name: string): number{ + if(undefined===Permissions.map[name]){ + console.error(name +" is not found in map",Permissions.map); + } if(this.getPermissionbit(Permissions.map[name] as number, this.allow)){ return 1; }else if( @@ -319,7 +322,7 @@ class Permissions{ } setPermission(name: string, setto: number): void{ const bit = Permissions.map[name] as number; - if(!bit){ + if(bit===undefined){ return console.error( "Tried to set permission to " + setto + diff --git a/src/webpage/role.ts b/src/webpage/role.ts index 6ab0848..8add9b6 100644 --- a/src/webpage/role.ts +++ b/src/webpage/role.ts @@ -44,9 +44,9 @@ export{ Role }; import{ Options }from"./settings.js"; class PermissionToggle implements OptionsElement{ readonly rolejson: { - name: string; - readableName: string; - description: string; + name: string; + readableName: string; + description: string; }; permissions: Permissions; owner: Options; @@ -177,4 +177,4 @@ class RoleList extends Buttons{ this.onchange(this.curid, this.permission); } } -export{ RoleList }; +export{ RoleList, PermissionToggle }; diff --git a/src/webpage/style.css b/src/webpage/style.css index 2321841..3add8c8 100644 --- a/src/webpage/style.css +++ b/src/webpage/style.css @@ -452,6 +452,7 @@ p { /* display: flex; */ width: 100%; background: transparent; + flex-shrink: 0; } hr { border-style: solid; @@ -538,9 +539,11 @@ hr { flex-direction: column; flex-shrink: 1; min-height: 0; - height: 100vh; + /* height: 100vh; */ /* width: 100%; */ position: relative; + height: 1in; + flex-grow: 1; } .timestamp { @@ -1268,7 +1271,7 @@ span { .flexttb{ display: flex; flex-direction: column; - max-height: 100vh; + /* max-height: 100vh; */ overflow: auto; /* margin-bottom: 1in; */ /* padding-bottom: .1in; */ @@ -1371,6 +1374,8 @@ span { display:flex; justify-content: space-between; width: 100%; + height: 100dvh; + align-content: space-around; } .userflex{ display:flex; @@ -1529,6 +1534,7 @@ span { .scroller{ padding-bottom: .2in; flex-grow: 0; + flex-shrink: 1; } .suberror{ animation: goout 6s forwards;