~kris/9p

glenda

fed0daaacea34ffac16836b16496badafa92c67a — arwn 4 years ago f7a8f35
add invite
2 files changed, 19 insertions(+), 0 deletions(-)

M mux.go
A x/mux/invite.go
M mux.go => mux.go +2 -0
@@ 24,6 24,8 @@ func init() {

	Router.Route("newuser", "Information for new users of Plan 9.", Router.Newuser)

	Router.Route("invite", "Generate a single use invite", Router.Invite)

	Router.Route("remindme", "Set a reminder for a given time interval ([int][hmsd] [reminder]).", Router.RemindMe)

	Router.Route("man", "Link a given Plan 9 manual page (From 9front for now).", Router.Man)

A x/mux/invite.go => x/mux/invite.go +17 -0
@@ 0,0 1,17 @@
package mux

import (
	"github.com/bwmarrin/discordgo"
)

// Display basic information about the bot
func (m *Mux) Invite(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) {
	invite := discordgo.Invite{MaxUses: 1}
	st, err := ds.ChannelInviteCreate(dm.ChannelID, invite)
	if err != nil {
		ds.ChannelMessageSend(dm.ChannelID, "Error generating invite: "+err.Error())
		return
	}

	ds.ChannelMessageSend(dm.ChannelID, "https://discord.gg/"+st.Code+"\n")
}