createinvite

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &commands.YAGCommand{
	Cooldown:             2,
	CmdCategory:          commands.CategoryDebug,
	HideFromCommandsPage: true,
	Name:                 "createinvite",
	Description:          "Maintenance command, creates a invite for the specified server",
	HideFromHelp:         true,
	RequiredArgs:         1,
	Arguments: []*dcmd.ArgDef{
		{Name: "server", Type: dcmd.Int},
	},
	RunFunc: util.RequireBotAdmin(func(data *dcmd.Data) (interface{}, error) {
		gs := bot.State.Guild(true, data.Args[0].Int64())
		if gs == nil {
			return "Unknown server", nil
		}

		channelID := int64(0)
		gs.RLock()
		for _, v := range gs.Channels {
			if channelID == 0 || v.Type != discordgo.ChannelTypeGuildVoice {
				channelID = v.ID
				if v.Type != discordgo.ChannelTypeGuildVoice {
					break
				}
			}
		}
		gs.RUnlock()

		if channelID == 0 {
			return "No possible channel :(", nil
		}

		invite, err := common.BotSession.ChannelInviteCreate(channelID, discordgo.Invite{
			MaxAge:  120,
			MaxUses: 1,
		})

		if err != nil {
			return nil, err
		}

		bot.SendDM(data.Msg.Author.ID, "discord.gg/"+invite.Code)
		return "Sent invite expiring in 120 seconds and with 1 use in DM", nil
	}),
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL